| 438 | |
| 439 | template <typename I> |
| 440 | constexpr I log2(I value) noexcept { |
| 441 | static_assert(std::is_integral_v<I>, "magic_enum::detail::log2 requires integral type."); |
| 442 | |
| 443 | if constexpr (std::is_same_v<I, bool>) { // bool special case |
| 444 | return MAGIC_ENUM_ASSERT(false), value; |
| 445 | } else { |
| 446 | auto ret = I{0}; |
| 447 | for (; value > I{1}; value >>= I{1}, ++ret) {} |
| 448 | |
| 449 | return ret; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | #if defined(__cpp_lib_array_constexpr) && __cpp_lib_array_constexpr >= 201603L |
| 454 | # define MAGIC_ENUM_ARRAY_CONSTEXPR 1 |
no outgoing calls
no test coverage detected