MCPcopy Create free account
hub / github.com/Neargye/magic_enum / log2

Function log2

include/magic_enum/magic_enum.hpp:440–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438
439template <typename I>
440constexpr 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

Callers 4

is_sparseFunction · 0.85
enum_valueFunction · 0.85
fuse_one_enumFunction · 0.85
enum_fuseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected