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

Function is_sparse

include/magic_enum/magic_enum.hpp:896–908  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

894
895template <typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
896constexpr bool is_sparse() noexcept {
897 if constexpr (count_v<E, S> == 0) {
898 return false;
899 } else if constexpr (std::is_same_v<U, bool>) { // bool special case
900 return false;
901 } else {
902 constexpr auto max = (S == enum_subtype::flags) ? log2(max_v<E, S>) : max_v<E, S>;
903 constexpr auto min = (S == enum_subtype::flags) ? log2(min_v<E, S>) : min_v<E, S>;
904 constexpr auto range_size = max - min + 1;
905
906 return range_size != count_v<E, S>;
907 }
908}
909
910template <typename E, enum_subtype S = subtype_v<E>>
911inline constexpr bool is_sparse_v = is_sparse<E, S>();

Callers

nothing calls this directly

Calls 1

log2Function · 0.85

Tested by

no test coverage detected