| 389 | |
| 390 | template <typename I> |
| 391 | constexpr I log2(I value) noexcept { |
| 392 | static_assert(std::is_integral_v<I>, "magic_enum::detail::log2 requires integral type."); |
| 393 | |
| 394 | if constexpr (std::is_same_v<I, bool>) { // bool special case |
| 395 | return MAGIC_ENUM_ASSERT(false), value; |
| 396 | } else { |
| 397 | auto ret = I{0}; |
| 398 | for (; value > I{1}; value >>= I{1}, ++ret) {} |
| 399 | |
| 400 | return ret; |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | #if defined(__cpp_lib_array_constexpr) && __cpp_lib_array_constexpr >= 201603L |
| 405 | # define MAGIC_ENUM_ARRAY_CONSTEXPR 1 |
no outgoing calls
no test coverage detected