magic_enum::detail Namespace Reference

Classes

class  case_insensitive
 
struct  enable_if_enum
 
struct  enable_if_enum< true, R >
 
struct  has_is_flags
 
struct  has_is_flags< T, std::void_t< decltype(customize::enum_range< T >::is_flags)> >
 
struct  is_scoped_enum
 
struct  is_scoped_enum< T, true >
 
struct  is_unscoped_enum
 
struct  is_unscoped_enum< T, true >
 
struct  range_max
 
struct  range_max< T, std::void_t< decltype(customize::enum_range< T >::max)> >
 
struct  range_min
 
struct  range_min< T, std::void_t< decltype(customize::enum_range< T >::min)> >
 
class  static_str
 
class  static_str< 0 >
 
struct  str_view
 
struct  supported
 
struct  underlying_type
 
struct  underlying_type< T, true >
 
struct  valid_count_t
 

Typedefs

template<typename T, typename R, typename BinaryPredicate = std::equal_to<>, typename D = std::decay_t<T>>
using enable_if_t = typename enable_if_enum<std::is_enum_v<D> && std::is_invocable_r_v<bool, BinaryPredicate, char_type, char_type>, R>::type
 
template<typename E, enum_subtype S, typename D = std::decay_t<E>>
using entries_t = decltype((entries_v<D, S>))
 
template<typename T, std::enable_if_t< std::is_enum_v< std::decay_t< T > >, int > = 0>
using enum_concept = T
 
template<auto V, typename E = std::decay_t<decltype(V)>, std::enable_if_t< std::is_enum_v< E >, int > = 0>
using enum_constant = std::integral_constant<E, V>
 
template<typename E, enum_subtype S, typename D = std::decay_t<E>>
using names_t = decltype((names_v<D, S>))
 
template<typename E, enum_subtype S, typename D = std::decay_t<E>>
using values_t = decltype((values_v<D, S>))
 

Enumerations

enum class  enum_subtype { common , flags }
 

Functions

template<typename BinaryPredicate>
constexpr bool cmp_equal (string_view lhs, string_view rhs, BinaryPredicate &&p) noexcept(is_nothrow_invocable< BinaryPredicate >())
 
template<typename L, typename R>
constexpr bool cmp_less (L lhs, R rhs) noexcept
 
template<typename E, enum_subtype S, std::size_t... I>
constexpr auto entries (std::index_sequence< I... >) noexcept
 
template<typename E, E V>
constexpr auto enum_name () noexcept
 
constexpr std::size_t find (string_view str, char_type c) noexcept
 
template<typename BinaryPredicate>
constexpr bool is_default_predicate () noexcept
 
template<typename BinaryPredicate>
constexpr bool is_nothrow_invocable ()
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr bool is_sparse () noexcept
 
template<typename E, auto V>
constexpr bool is_valid () noexcept
 
template<typename I>
constexpr I log2 (I value) noexcept
 
template<typename E>
constexpr auto n () noexcept
 
template<typename E, enum_subtype S, std::size_t... I>
constexpr auto names (std::index_sequence< I... >) noexcept
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr int reflected_max () noexcept
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr int reflected_min () noexcept
 
template<typename T>
constexpr enum_subtype subtype (std::false_type) noexcept
 
template<typename E, typename U = std::underlying_type_t<E>>
constexpr enum_subtype subtype (std::true_type) noexcept
 
template<typename T, std::size_t N, std::size_t... I>
constexpr std::array< std::remove_cv_t< T >, N > to_array (T(&a)[N], std::index_sequence< I... >) noexcept
 
template<typename E>
constexpr auto type_name () noexcept
 
template<typename E, int O, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr U ualue (std::size_t i) noexcept
 
template<typename E, enum_subtype S, std::size_t Size, int Min>
constexpr auto valid_count () noexcept
 
template<typename E, enum_subtype S, std::size_t Size, int Min, std::size_t I>
constexpr void valid_count (bool *valid, std::size_t &count) noexcept
 
template<typename E, int O, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr E value (std::size_t i) noexcept
 
template<typename E, enum_subtype S, std::size_t Size, int Min>
constexpr auto values () noexcept
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr auto values () noexcept
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr U values_ors () noexcept
 

Variables

template<typename... T>
constexpr bool always_false_v = false
 
template<typename E, enum_subtype S>
constexpr auto count_v = values_v<E, S>.size()
 
template<typename E, enum_subtype S>
constexpr auto entries_v = entries<E, S>(std::make_index_sequence<count_v<E, S>>{})
 
template<typename E, E V>
constexpr auto enum_name_v = enum_name<E, V>()
 
template<typename T>
constexpr bool is_enum_v = std::is_enum_v<T> && std::is_same_v<T, std::decay_t<T>>
 
template<typename E, enum_subtype S = subtype_v<E>>
constexpr bool is_sparse_v = is_sparse<E, S>()
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr auto max_v = (count_v<E, S> > 0) ? static_cast<U>(values_v<E, S>.back()) : U{0}
 
template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr auto min_v = (count_v<E, S> > 0) ? static_cast<U>(values_v<E, S>.front()) : U{0}
 
template<typename E, enum_subtype S>
constexpr auto names_v = names<E, S>(std::make_index_sequence<count_v<E, S>>{})
 
template<typename E, typename D = std::decay_t<E>>
constexpr auto subtype_v = subtype<D>(std::is_enum<D>{})
 
template<typename E>
constexpr auto type_name_v = type_name<E>()
 
template<typename E, enum_subtype S>
constexpr auto values_v = values<E, S>()
 

Typedef Documentation

◆ enable_if_t

template<typename T, typename R, typename BinaryPredicate = std::equal_to<>, typename D = std::decay_t<T>>
using enable_if_t = typename enable_if_enum<std::is_enum_v<D> && std::is_invocable_r_v<bool, BinaryPredicate, char_type, char_type>, R>::type

◆ entries_t

template<typename E, enum_subtype S, typename D = std::decay_t<E>>
using entries_t = decltype((entries_v<D, S>))

◆ enum_concept

template<typename T, std::enable_if_t< std::is_enum_v< std::decay_t< T > >, int > = 0>
using enum_concept = T

◆ enum_constant

template<auto V, typename E = std::decay_t<decltype(V)>, std::enable_if_t< std::is_enum_v< E >, int > = 0>
using enum_constant = std::integral_constant<E, V>

◆ names_t

template<typename E, enum_subtype S, typename D = std::decay_t<E>>
using names_t = decltype((names_v<D, S>))

◆ values_t

template<typename E, enum_subtype S, typename D = std::decay_t<E>>
using values_t = decltype((values_v<D, S>))

Enumeration Type Documentation

◆ enum_subtype

enum class enum_subtype
strong
Enumerator
common 
flags 

Function Documentation

◆ cmp_equal()

template<typename BinaryPredicate>
bool cmp_equal ( string_view lhs,
string_view rhs,
BinaryPredicate && p )
constexprnoexcept

◆ cmp_less()

template<typename L, typename R>
bool cmp_less ( L lhs,
R rhs )
constexprnoexcept

◆ entries()

template<typename E, enum_subtype S, std::size_t... I>
auto entries ( std::index_sequence< I... > )
constexprnoexcept

◆ enum_name()

template<typename E, E V>
auto enum_name ( )
constexprnoexcept

◆ find()

std::size_t find ( string_view str,
char_type c )
constexprnoexcept

◆ is_default_predicate()

template<typename BinaryPredicate>
bool is_default_predicate ( )
constexprnoexcept

◆ is_nothrow_invocable()

template<typename BinaryPredicate>
bool is_nothrow_invocable ( )
constexpr

◆ is_sparse()

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
bool is_sparse ( )
constexprnoexcept

◆ is_valid()

template<typename E, auto V>
bool is_valid ( )
constexprnoexcept

◆ log2()

template<typename I>
I log2 ( I value)
constexprnoexcept

◆ n()

template<typename E>
auto n ( )
constexprnoexcept

◆ names()

template<typename E, enum_subtype S, std::size_t... I>
auto names ( std::index_sequence< I... > )
constexprnoexcept

◆ reflected_max()

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
int reflected_max ( )
constexprnoexcept

◆ reflected_min()

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
int reflected_min ( )
constexprnoexcept

◆ subtype() [1/2]

template<typename T>
enum_subtype subtype ( std::false_type )
constexprnoexcept

◆ subtype() [2/2]

template<typename E, typename U = std::underlying_type_t<E>>
enum_subtype subtype ( std::true_type )
constexprnoexcept

◆ to_array()

template<typename T, std::size_t N, std::size_t... I>
std::array< std::remove_cv_t< T >, N > to_array ( T(&) a[N],
std::index_sequence< I... >  )
constexprnoexcept

◆ type_name()

template<typename E>
auto type_name ( )
constexprnoexcept

◆ ualue()

template<typename E, int O, enum_subtype S, typename U = std::underlying_type_t<E>>
U ualue ( std::size_t i)
constexprnoexcept

◆ valid_count() [1/2]

template<typename E, enum_subtype S, std::size_t Size, int Min>
auto valid_count ( )
constexprnoexcept

◆ valid_count() [2/2]

template<typename E, enum_subtype S, std::size_t Size, int Min, std::size_t I>
void valid_count ( bool * valid,
std::size_t & count )
constexprnoexcept

◆ value()

template<typename E, int O, enum_subtype S, typename U = std::underlying_type_t<E>>
E value ( std::size_t i)
constexprnoexcept

◆ values() [1/2]

template<typename E, enum_subtype S, std::size_t Size, int Min>
auto values ( )
constexprnoexcept

◆ values() [2/2]

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
auto values ( )
constexprnoexcept

◆ values_ors()

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
U values_ors ( )
constexprnoexcept

Variable Documentation

◆ always_false_v

template<typename... T>
bool always_false_v = false
inlineconstexpr

◆ count_v

template<typename E, enum_subtype S>
auto count_v = values_v<E, S>.size()
inlineconstexpr

◆ entries_v

template<typename E, enum_subtype S>
auto entries_v = entries<E, S>(std::make_index_sequence<count_v<E, S>>{})
inlineconstexpr

◆ enum_name_v

template<typename E, E V>
auto enum_name_v = enum_name<E, V>()
inlineconstexpr

◆ is_enum_v

template<typename T>
bool is_enum_v = std::is_enum_v<T> && std::is_same_v<T, std::decay_t<T>>
inlineconstexpr

◆ is_sparse_v

template<typename E, enum_subtype S = subtype_v<E>>
bool is_sparse_v = is_sparse<E, S>()
inlineconstexpr

◆ max_v

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
auto max_v = (count_v<E, S> > 0) ? static_cast<U>(values_v<E, S>.back()) : U{0}
inlineconstexpr

◆ min_v

template<typename E, enum_subtype S, typename U = std::underlying_type_t<E>>
auto min_v = (count_v<E, S> > 0) ? static_cast<U>(values_v<E, S>.front()) : U{0}
inlineconstexpr

◆ names_v

template<typename E, enum_subtype S>
auto names_v = names<E, S>(std::make_index_sequence<count_v<E, S>>{})
inlineconstexpr

◆ subtype_v

template<typename E, typename D = std::decay_t<E>>
auto subtype_v = subtype<D>(std::is_enum<D>{})
inlineconstexpr

◆ type_name_v

template<typename E>
auto type_name_v = type_name<E>()
inlineconstexpr

◆ values_v

template<typename E, enum_subtype S>
auto values_v = values<E, S>()
inlineconstexpr