hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
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_reflected
 
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<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 values_t = decltype((values_v< D, S >))
 
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 entries_t = decltype((entries_v< D, S >))
 
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 T , std::enable_if_t< std::is_enum_v< std::decay_t< T > >, int > = 0>
using enum_concept = T
 

Enumerations

enum class  enum_subtype { common , flags }
 

Functions

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 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 I >
constexpr I log2 (I value) 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 n () noexcept
 
template<typename E >
constexpr auto type_name () noexcept
 
template<typename E , E V>
constexpr auto enum_name () noexcept
 
template<typename E , auto V>
constexpr bool is_valid () 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 , 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, typename U = std::underlying_type_t<E>>
constexpr int reflected_min () 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, std::size_t Size, int Min, std::size_t I>
constexpr void valid_count (bool *valid, std::size_t &count) 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>
constexpr auto values () noexcept
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr auto values () noexcept
 
template<typename E , typename U = std::underlying_type_t<E>>
constexpr enum_subtype subtype (std::true_type) noexcept
 
template<typename T >
constexpr enum_subtype subtype (std::false_type) 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, std::size_t... I>
constexpr auto entries (std::index_sequence< I... >) noexcept
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr bool is_sparse () noexcept
 

Variables

template<typename... T>
constexpr bool always_false_v = false
 
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 >
constexpr auto type_name_v = type_name<E>()
 
template<typename E , E V>
constexpr auto enum_name_v = enum_name<E, V>()
 
template<typename E , typename D = std::decay_t<E>>
constexpr auto subtype_v = subtype<D>(std::is_enum<D>{})
 
template<typename E , enum_subtype S>
constexpr auto values_v = values<E, S>()
 
template<typename E , enum_subtype S>
constexpr auto count_v = values_v<E, S>.size()
 
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, 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>
constexpr auto names_v = names<E, S>(std::make_index_sequence<count_v<E, S>>{})
 
template<typename E , enum_subtype S>
constexpr auto entries_v = entries<E, S>(std::make_index_sequence<count_v<E, S>>{})
 
template<typename E , enum_subtype S = subtype_v<E>>
constexpr bool is_sparse_v = is_sparse<E, S>()
 
template<typename E , enum_subtype S>
constexpr bool is_reflected_v = is_reflected<std::decay_t<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

Definition at line 893 of file magic_enum.h.

◆ entries_t

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

Definition at line 852 of file magic_enum.h.

◆ enum_concept

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

Definition at line 896 of file magic_enum.h.

◆ 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>

Definition at line 228 of file magic_enum.h.

◆ names_t

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

Definition at line 840 of file magic_enum.h.

◆ values_t

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

Definition at line 819 of file magic_enum.h.

Enumeration Type Documentation

◆ enum_subtype

enum class enum_subtype
strong
Enumerator
common 
flags 

Definition at line 649 of file magic_enum.h.

Function Documentation

◆ cmp_equal()

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

Definition at line 347 of file magic_enum.h.

◆ cmp_less()

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

Definition at line 375 of file magic_enum.h.

Referenced by reflected_max(), and reflected_min().

Here is the caller graph for this function:

◆ entries()

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

Definition at line 843 of file magic_enum.h.

References entries().

Referenced by entries().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enum_name()

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

◆ find()

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

Definition at line 312 of file magic_enum.h.

◆ is_default_predicate()

template<typename BinaryPredicate >
constexpr bool is_default_predicate ( )
constexprnoexcept

Definition at line 335 of file magic_enum.h.

◆ is_nothrow_invocable()

template<typename BinaryPredicate >
constexpr bool is_nothrow_invocable ( )
constexpr

Definition at line 341 of file magic_enum.h.

◆ is_sparse()

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

Definition at line 855 of file magic_enum.h.

References flags, and log2().

Here is the call graph for this function:

◆ is_valid()

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

◆ log2()

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

Definition at line 395 of file magic_enum.h.

References MAGIC_ENUM_ASSERT, and value().

Referenced by magic_enum::enum_value(), and is_sparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ n()

template<typename E >
constexpr auto n ( )
constexprnoexcept

Definition at line 421 of file magic_enum.h.

References str_view::size_, and str_view::str_.

◆ names()

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

Definition at line 831 of file magic_enum.h.

References names().

Referenced by names().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reflected_max()

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

Definition at line 689 of file magic_enum.h.

References cmp_less(), and flags.

Here is the call graph for this function:

◆ reflected_min()

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

Definition at line 673 of file magic_enum.h.

References cmp_less(), and flags.

Here is the call graph for this function:

◆ subtype() [1/2]

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

Definition at line 807 of file magic_enum.h.

References common.

◆ subtype() [2/2]

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

Definition at line 781 of file magic_enum.h.

References common, and flags.

◆ to_array()

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... >   
)
constexprnoexcept

Definition at line 412 of file magic_enum.h.

Referenced by values().

Here is the caller graph for this function:

◆ type_name()

template<typename E >
constexpr auto type_name ( )
constexprnoexcept

◆ ualue()

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

Definition at line 655 of file magic_enum.h.

References flags.

◆ valid_count() [1/2]

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

Definition at line 739 of file magic_enum.h.

References valid_count_t< N >::count, and valid_count_t< N >::valid.

◆ valid_count() [2/2]

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 
)
constexprnoexcept

Definition at line 715 of file magic_enum.h.

References MAGIC_ENUM_FOR_EACH_256, and MAGIC_ENUM_V.

◆ value()

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

Definition at line 668 of file magic_enum.h.

Referenced by log2().

Here is the caller graph for this function:

◆ values() [1/2]

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

Definition at line 746 of file magic_enum.h.

References to_array(), and values().

Referenced by values().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ values() [2/2]

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

Definition at line 771 of file magic_enum.h.

Variable Documentation

◆ always_false_v

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

Definition at line 231 of file magic_enum.h.

◆ count_v

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

Definition at line 822 of file magic_enum.h.

◆ entries_v

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

Definition at line 849 of file magic_enum.h.

◆ enum_name_v

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

Definition at line 622 of file magic_enum.h.

Referenced by magic_enum::enum_name().

◆ is_enum_v

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

Definition at line 418 of file magic_enum.h.

◆ is_reflected_v

template<typename E , enum_subtype S>
constexpr bool is_reflected_v = is_reflected<std::decay_t<E>, S>{}
inlineconstexpr

Definition at line 881 of file magic_enum.h.

◆ is_sparse_v

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

Definition at line 870 of file magic_enum.h.

◆ max_v

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}
inlineconstexpr

Definition at line 828 of file magic_enum.h.

◆ min_v

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}
inlineconstexpr

Definition at line 825 of file magic_enum.h.

◆ names_v

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

Definition at line 837 of file magic_enum.h.

◆ subtype_v

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

Definition at line 813 of file magic_enum.h.

◆ type_name_v

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

Definition at line 494 of file magic_enum.h.

◆ values_v

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

Definition at line 816 of file magic_enum.h.