magic_enum Namespace Reference

Namespaces

namespace  bitwise_operators
 
namespace  customize
 
namespace  detail
 

Classes

struct  is_scoped_enum
 
struct  is_unscoped_enum
 
struct  underlying_type
 

Typedefs

using char_type = string_view::value_type
 
template<typename T>
using Enum = detail::enum_concept<T>
 
template<auto V>
using enum_constant = detail::enum_constant<V>
 
template<typename T>
using underlying_type_t = typename underlying_type<T>::type
 

Functions

template<typename E, detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
constexpr auto enum_cast (string_view value, BinaryPredicate p={}) noexcept(detail::is_nothrow_invocable< BinaryPredicate >()) -> detail::enable_if_t< E, optional< std::decay_t< E > >, BinaryPredicate >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_cast (underlying_type_t< E > value) noexcept -> detail::enable_if_t< E, optional< std::decay_t< E > > >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_contains (E value) noexcept -> detail::enable_if_t< E, bool >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
constexpr auto enum_contains (string_view value, BinaryPredicate p={}) noexcept(detail::is_nothrow_invocable< BinaryPredicate >()) -> detail::enable_if_t< E, bool, BinaryPredicate >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_contains (underlying_type_t< E > value) noexcept -> detail::enable_if_t< E, bool >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_count () noexcept -> detail::enable_if_t< E, std::size_t >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_entries () noexcept -> detail::enable_if_t< E, detail::entries_t< E, S > >
 
template<auto V, detail::enum_subtype S = detail::subtype_v<std::decay_t<decltype(V)>>>
constexpr auto enum_index () noexcept -> detail::enable_if_t< decltype(V), std::size_t >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_index (E value) noexcept -> detail::enable_if_t< E, optional< std::size_t > >
 
template<typename E>
constexpr auto enum_integer (E value) noexcept -> detail::enable_if_t< E, underlying_type_t< E > >
 
template<auto V>
constexpr auto enum_name () noexcept -> detail::enable_if_t< decltype(V), string_view >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_name (E value) noexcept -> detail::enable_if_t< E, string_view >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_names () noexcept -> detail::enable_if_t< E, detail::names_t< E, S > >
 
template<typename E>
constexpr auto enum_type_name () noexcept -> detail::enable_if_t< E, string_view >
 
template<typename E>
constexpr auto enum_underlying (E value) noexcept -> detail::enable_if_t< E, underlying_type_t< E > >
 
template<typename E, std::size_t I, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_value () noexcept -> detail::enable_if_t< E, std::decay_t< E > >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_value (std::size_t index) noexcept -> detail::enable_if_t< E, std::decay_t< E > >
 
template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto enum_values () noexcept -> detail::enable_if_t< E, detail::values_t< E, S > >
 

Variables

template<bool AsFlags = true>
constexpr auto as_common = AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags
 
template<bool AsFlags = true>
constexpr auto as_flags = AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common
 
constexpr auto case_insensitive = detail::case_insensitive<>{}
 
constexpr bool is_magic_enum_supported = detail::supported<void>::value
 
template<typename T>
constexpr bool is_scoped_enum_v = is_scoped_enum<T>::value
 
template<typename T>
constexpr bool is_unscoped_enum_v = is_unscoped_enum<T>::value
 

Typedef Documentation

◆ char_type

using char_type = string_view::value_type

Definition at line 143 of file magic_enum.hpp.

◆ Enum

template<typename T>
using Enum = detail::enum_concept<T>

Definition at line 1100 of file magic_enum.hpp.

◆ enum_constant

template<auto V>
using enum_constant = detail::enum_constant<V>

Definition at line 1127 of file magic_enum.hpp.

◆ underlying_type_t

template<typename T>
using underlying_type_t = typename underlying_type<T>::type

Definition at line 1124 of file magic_enum.hpp.

Function Documentation

◆ enum_cast() [1/2]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
auto enum_cast ( string_view value,
BinaryPredicate p = {} ) -> detail::enable_if_t<E, optional<std::decay_t<E>>, BinaryPredicate>
nodiscardconstexprnoexcept

Definition at line 1319 of file magic_enum.hpp.

◆ enum_cast() [2/2]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_cast ( underlying_type_t< E > value) -> detail::enable_if_t<E, optional<std::decay_t<E>>>
nodiscardconstexprnoexcept

Definition at line 1286 of file magic_enum.hpp.

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

◆ enum_contains() [1/3]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_contains ( E value) -> detail::enable_if_t<E, bool>
nodiscardconstexprnoexcept

Definition at line 1345 of file magic_enum.hpp.

+ Here is the call graph for this function:

◆ enum_contains() [2/3]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
auto enum_contains ( string_view value,
BinaryPredicate p = {} ) -> detail::enable_if_t<E, bool, BinaryPredicate>
nodiscardconstexprnoexcept

Definition at line 1371 of file magic_enum.hpp.

◆ enum_contains() [3/3]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_contains ( underlying_type_t< E > value) -> detail::enable_if_t<E, bool>
nodiscardconstexprnoexcept

Definition at line 1363 of file magic_enum.hpp.

+ Here is the call graph for this function:

◆ enum_count()

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_count ( ) -> detail::enable_if_t<E, std::size_t>
nodiscardconstexprnoexcept

Definition at line 1140 of file magic_enum.hpp.

◆ enum_entries()

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_entries ( ) -> detail::enable_if_t<E, detail::entries_t<E, S>>
nodiscardconstexprnoexcept

Definition at line 1276 of file magic_enum.hpp.

◆ enum_index() [1/2]

template<auto V, detail::enum_subtype S = detail::subtype_v<std::decay_t<decltype(V)>>>
auto enum_index ( ) -> detail::enable_if_t<decltype(V), std::size_t>
nodiscardconstexprnoexcept

Definition at line 1230 of file magic_enum.hpp.

+ Here is the call graph for this function:

◆ enum_index() [2/2]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_index ( E value) -> detail::enable_if_t<E, optional<std::size_t>>
nodiscardconstexprnoexcept

Definition at line 1189 of file magic_enum.hpp.

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

◆ enum_integer()

template<typename E>
auto enum_integer ( E value) -> detail::enable_if_t<E, underlying_type_t<E>>
nodiscardconstexprnoexcept

Definition at line 1176 of file magic_enum.hpp.

◆ enum_name() [1/2]

template<auto V>
auto enum_name ( ) -> detail::enable_if_t<decltype(V), string_view>
nodiscardconstexprnoexcept

Definition at line 1240 of file magic_enum.hpp.

◆ enum_name() [2/2]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_name ( E value) -> detail::enable_if_t<E, string_view>
nodiscardconstexprnoexcept

Definition at line 1250 of file magic_enum.hpp.

+ Here is the call graph for this function:

◆ enum_names()

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_names ( ) -> detail::enable_if_t<E, detail::names_t<E, S>>
nodiscardconstexprnoexcept

Definition at line 1270 of file magic_enum.hpp.

◆ enum_type_name()

template<typename E>
auto enum_type_name ( ) -> detail::enable_if_t<E, string_view>
nodiscardconstexprnoexcept

Definition at line 1131 of file magic_enum.hpp.

◆ enum_underlying()

template<typename E>
auto enum_underlying ( E value) -> detail::enable_if_t<E, underlying_type_t<E>>
nodiscardconstexprnoexcept

Definition at line 1182 of file magic_enum.hpp.

◆ enum_value() [1/2]

template<typename E, std::size_t I, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_value ( ) -> detail::enable_if_t<E, std::decay_t<E>>
nodiscardconstexprnoexcept

Definition at line 1161 of file magic_enum.hpp.

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

◆ enum_value() [2/2]

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_value ( std::size_t index) -> detail::enable_if_t<E, std::decay_t<E>>
nodiscardconstexprnoexcept

Definition at line 1147 of file magic_enum.hpp.

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

◆ enum_values()

template<typename E, detail::enum_subtype S = detail::subtype_v<E>>
auto enum_values ( ) -> detail::enable_if_t<E, detail::values_t<E, S>>
nodiscardconstexprnoexcept

Definition at line 1170 of file magic_enum.hpp.

Variable Documentation

◆ as_common

template<bool AsFlags = true>
auto as_common = AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags
inlineconstexpr

Definition at line 1381 of file magic_enum.hpp.

◆ as_flags

template<bool AsFlags = true>
auto as_flags = AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common
inlineconstexpr

Definition at line 1378 of file magic_enum.hpp.

◆ case_insensitive

auto case_insensitive = detail::case_insensitive<>{}
inlineconstexpr

Definition at line 1281 of file magic_enum.hpp.

◆ is_magic_enum_supported

bool is_magic_enum_supported = detail::supported<void>::value
inlineconstexpr

Definition at line 1097 of file magic_enum.hpp.

◆ is_scoped_enum_v

template<typename T>
bool is_scoped_enum_v = is_scoped_enum<T>::value
inlineconstexpr

Definition at line 1116 of file magic_enum.hpp.

◆ is_unscoped_enum_v

template<typename T>
bool is_unscoped_enum_v = is_unscoped_enum<T>::value
inlineconstexpr

Definition at line 1108 of file magic_enum.hpp.