Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
magic_enum.hpp File Reference
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
#include <type_traits>
#include <utility>
#include <optional>
#include <string>
#include <string_view>
#include <cassert>
Include dependency graph for magic_enum.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  magic_enum::detail::case_insensitive< Op >
 
class  magic_enum::customize::customize_t
 
struct  magic_enum::detail::enable_if_enum< bool, R >
 
struct  magic_enum::detail::enable_if_enum< true, R >
 
struct  magic_enum::customize::enum_range< E >
 
struct  magic_enum::detail::has_is_flags< T, typename >
 
struct  magic_enum::detail::has_is_flags< T, std::void_t< decltype(customize::enum_range< T >::is_flags)> >
 
struct  magic_enum::detail::is_reflected< E, S >
 
struct  magic_enum::is_scoped_enum< T >
 
struct  magic_enum::detail::is_scoped_enum< T, bool >
 
struct  magic_enum::detail::is_scoped_enum< T, true >
 
struct  magic_enum::is_unscoped_enum< T >
 
struct  magic_enum::detail::is_unscoped_enum< T, bool >
 
struct  magic_enum::detail::is_unscoped_enum< T, true >
 
struct  magic_enum::detail::range_max< T, typename >
 
struct  magic_enum::detail::range_max< T, std::void_t< decltype(customize::enum_range< T >::max)> >
 
struct  magic_enum::detail::range_min< T, typename >
 
struct  magic_enum::detail::range_min< T, std::void_t< decltype(customize::enum_range< T >::min)> >
 
class  magic_enum::detail::static_str< N >
 
class  magic_enum::detail::static_str< 0 >
 
struct  magic_enum::detail::str_view
 
struct  magic_enum::detail::supported< T >
 
struct  magic_enum::underlying_type< T >
 
struct  magic_enum::detail::underlying_type< T, bool >
 
struct  magic_enum::detail::underlying_type< T, true >
 
struct  magic_enum::detail::valid_count_t< N >
 

Namespaces

 magic_enum
 
 magic_enum::bitwise_operators
 
 magic_enum::customize
 
 magic_enum::customize::detail
 
 magic_enum::detail
 

Macros

#define MAGIC_ENUM_ASSERT(...)   assert((__VA_ARGS__))
 
#define MAGIC_ENUM_FOR_EACH_256(T)
 
#define MAGIC_ENUM_RANGE_MAX   127
 
#define MAGIC_ENUM_RANGE_MIN   -128
 
#define MAGIC_ENUM_V(O)
 
#define MAGIC_ENUM_VERSION_MAJOR   0
 
#define MAGIC_ENUM_VERSION_MINOR   9
 
#define MAGIC_ENUM_VERSION_PATCH   5
 

Typedefs

using magic_enum::char_type = string_view::value_type
 
template<typename T , typename R , typename BinaryPredicate = std::equal_to<>, typename D = std::decay_t<T>>
using magic_enum::detail::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 magic_enum::detail::entries_t = decltype((entries_v< D, S >))
 
template<typename T >
using magic_enum::Enum = detail::enum_concept< T >
 
template<typename T , std::enable_if_t< std::is_enum_v< std::decay_t< T >>, int > = 0>
using magic_enum::detail::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 magic_enum::detail::enum_constant = std::integral_constant< E, V >
 
template<auto V>
using magic_enum::enum_constant = detail::enum_constant< V >
 
template<typename E , enum_subtype S, typename D = std::decay_t<E>>
using magic_enum::detail::names_t = decltype((names_v< D, S >))
 
template<typename T >
using magic_enum::underlying_type_t = typename underlying_type< T >::type
 
template<typename E , enum_subtype S, typename D = std::decay_t<E>>
using magic_enum::detail::values_t = decltype((values_v< D, S >))
 

Enumerations

enum  magic_enum::customize::detail::customize_tag { magic_enum::customize::detail::customize_tag::default_tag, magic_enum::customize::detail::customize_tag::invalid_tag, magic_enum::customize::detail::customize_tag::custom_tag }
 
enum  magic_enum::detail::enum_subtype { magic_enum::detail::enum_subtype::common, magic_enum::detail::enum_subtype::flags }
 

Functions

template<typename BinaryPredicate >
constexpr bool magic_enum::detail::cmp_equal (string_view lhs, string_view rhs, [[maybe_unused]] BinaryPredicate &&p) noexcept(is_nothrow_invocable< BinaryPredicate >())
 
template<typename L , typename R >
constexpr bool magic_enum::detail::cmp_less (L lhs, R rhs) noexcept
 
template<typename E , enum_subtype S, std::size_t... I>
constexpr auto magic_enum::detail::entries (std::index_sequence< I... >) noexcept
 
template<typename E , detail::enum_subtype S = detail::subtype_v<E>, typename BinaryPredicate = std::equal_to<>>
constexpr auto magic_enum::enum_cast (string_view value, [[maybe_unused]] 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 magic_enum::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 magic_enum::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 magic_enum::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 magic_enum::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 magic_enum::enum_count () noexcept -> detail::enable_if_t< E, std::size_t >
 
template<typename E , detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto magic_enum::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 magic_enum::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 magic_enum::enum_index (E value) noexcept -> detail::enable_if_t< E, optional< std::size_t >>
 
template<typename E >
constexpr auto magic_enum::enum_integer (E value) noexcept -> detail::enable_if_t< E, underlying_type_t< E >>
 
template<typename E , E V>
constexpr auto magic_enum::detail::enum_name () noexcept
 
template<auto V>
constexpr auto magic_enum::enum_name () noexcept -> detail::enable_if_t< decltype(V), string_view >
 
template<typename E , detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto magic_enum::enum_name (E value) noexcept -> detail::enable_if_t< E, string_view >
 
template<typename E >
constexpr customize_t magic_enum::customize::enum_name (E) noexcept
 
template<typename E , detail::enum_subtype S = detail::subtype_v<E>>
constexpr auto magic_enum::enum_names () noexcept -> detail::enable_if_t< E, detail::names_t< E, S >>
 
template<typename E >
constexpr customize_t magic_enum::customize::enum_type_name () noexcept
 
template<typename E >
constexpr auto magic_enum::enum_type_name () noexcept -> detail::enable_if_t< E, string_view >
 
template<typename E >
constexpr auto magic_enum::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 magic_enum::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 magic_enum::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 magic_enum::enum_values () noexcept -> detail::enable_if_t< E, detail::values_t< E, S >>
 
constexpr std::size_t magic_enum::detail::find (string_view str, char_type c) noexcept
 
template<typename BinaryPredicate >
constexpr bool magic_enum::detail::is_default_predicate () noexcept
 
template<typename BinaryPredicate >
constexpr bool magic_enum::detail::is_nothrow_invocable ()
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr bool magic_enum::detail::is_sparse () noexcept
 
template<typename E , auto V>
constexpr bool magic_enum::detail::is_valid () noexcept
 
template<typename I >
constexpr I magic_enum::detail::log2 (I value) noexcept
 
template<typename E >
constexpr auto magic_enum::detail::n () noexcept
 
template<typename E , enum_subtype S, std::size_t... I>
constexpr auto magic_enum::detail::names (std::index_sequence< I... >) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E magic_enum::bitwise_operators::operator& (E lhs, E rhs) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E & magic_enum::bitwise_operators::operator&= (E &lhs, E rhs) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E magic_enum::bitwise_operators::operator^ (E lhs, E rhs) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E & magic_enum::bitwise_operators::operator^= (E &lhs, E rhs) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E magic_enum::bitwise_operators::operator| (E lhs, E rhs) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E & magic_enum::bitwise_operators::operator|= (E &lhs, E rhs) noexcept
 
template<typename E , detail::enable_if_t< E, int > = 0>
constexpr E magic_enum::bitwise_operators::operator~ (E rhs) noexcept
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr int magic_enum::detail::reflected_max () noexcept
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr int magic_enum::detail::reflected_min () noexcept
 
template<typename T >
constexpr enum_subtype magic_enum::detail::subtype (std::false_type) noexcept
 
template<typename E , typename U = std::underlying_type_t<E>>
constexpr enum_subtype magic_enum::detail::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 > magic_enum::detail::to_array (T(&a)[N], std::index_sequence< I... >) noexcept
 
template<typename E >
constexpr auto magic_enum::detail::type_name () noexcept
 
template<typename E , int O, enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr U magic_enum::detail::ualue (std::size_t i) noexcept
 
template<typename E , enum_subtype S, std::size_t Size, int Min>
constexpr auto magic_enum::detail::valid_count () noexcept
 
template<typename E , enum_subtype S, std::size_t Size, int Min, std::size_t I>
constexpr void magic_enum::detail::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 magic_enum::detail::value (std::size_t i) noexcept
 
template<typename E , enum_subtype S, std::size_t Size, int Min>
constexpr auto magic_enum::detail::values () noexcept
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr auto magic_enum::detail::values () noexcept
 

Variables

template<typename... T>
constexpr bool magic_enum::detail::always_false_v = false
 
template<bool AsFlags = true>
constexpr auto magic_enum::as_common = AsFlags ? detail::enum_subtype::common : detail::enum_subtype::flags
 
template<bool AsFlags = true>
constexpr auto magic_enum::as_flags = AsFlags ? detail::enum_subtype::flags : detail::enum_subtype::common
 
constexpr auto magic_enum::case_insensitive = detail::case_insensitive<>{}
 
template<typename E , enum_subtype S>
constexpr auto magic_enum::detail::count_v = values_v<E, S>.size()
 
constexpr auto magic_enum::customize::default_tag = customize_t{detail::customize_tag::default_tag}
 
template<typename E , enum_subtype S>
constexpr auto magic_enum::detail::entries_v = entries<E, S>(std::make_index_sequence<count_v<E, S>>{})
 
template<typename E , E V>
constexpr auto magic_enum::detail::enum_name_v = enum_name<E, V>()
 
constexpr auto magic_enum::customize::invalid_tag = customize_t{detail::customize_tag::invalid_tag}
 
template<typename T >
constexpr bool magic_enum::detail::is_enum_v = std::is_enum_v<T> && std::is_same_v<T, std::decay_t<T>>
 
constexpr bool magic_enum::is_magic_enum_supported = detail::supported<void>::value
 
template<typename E , enum_subtype S>
constexpr bool magic_enum::detail::is_reflected_v = is_reflected<std::decay_t<E>, S>{}
 
template<typename T >
constexpr bool magic_enum::is_scoped_enum_v = is_scoped_enum<T>::value
 
template<typename E , enum_subtype S = subtype_v<E>>
constexpr bool magic_enum::detail::is_sparse_v = is_sparse<E, S>()
 
template<typename T >
constexpr bool magic_enum::is_unscoped_enum_v = is_unscoped_enum<T>::value
 
template<typename E , enum_subtype S, typename U = std::underlying_type_t<E>>
constexpr auto magic_enum::detail::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 magic_enum::detail::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 magic_enum::detail::names_v = names<E, S>(std::make_index_sequence<count_v<E, S>>{})
 
template<typename E , typename D = std::decay_t<E>>
constexpr auto magic_enum::detail::subtype_v = subtype<D>(std::is_enum<D>{})
 
template<typename E >
constexpr auto magic_enum::detail::type_name_v = type_name<E>()
 
template<typename E , enum_subtype S>
constexpr auto magic_enum::detail::values_v = values<E, S>()
 

Macro Definition Documentation

◆ MAGIC_ENUM_ASSERT

#define MAGIC_ENUM_ASSERT (   ...)    assert((__VA_ARGS__))

Definition at line 65 of file magic_enum.hpp.

◆ MAGIC_ENUM_FOR_EACH_256

#define MAGIC_ENUM_FOR_EACH_256 (   T)
Value:
T( 0)T( 1)T( 2)T( 3)T( 4)T( 5)T( 6)T( 7)T( 8)T( 9)T( 10)T( 11)T( 12)T( 13)T( 14)T( 15)T( 16)T( 17)T( 18)T( 19)T( 20)T( 21)T( 22)T( 23)T( 24)T( 25)T( 26)T( 27)T( 28)T( 29)T( 30)T( 31) \
T( 32)T( 33)T( 34)T( 35)T( 36)T( 37)T( 38)T( 39)T( 40)T( 41)T( 42)T( 43)T( 44)T( 45)T( 46)T( 47)T( 48)T( 49)T( 50)T( 51)T( 52)T( 53)T( 54)T( 55)T( 56)T( 57)T( 58)T( 59)T( 60)T( 61)T( 62)T( 63) \
T( 64)T( 65)T( 66)T( 67)T( 68)T( 69)T( 70)T( 71)T( 72)T( 73)T( 74)T( 75)T( 76)T( 77)T( 78)T( 79)T( 80)T( 81)T( 82)T( 83)T( 84)T( 85)T( 86)T( 87)T( 88)T( 89)T( 90)T( 91)T( 92)T( 93)T( 94)T( 95) \
T( 96)T( 97)T( 98)T( 99)T(100)T(101)T(102)T(103)T(104)T(105)T(106)T(107)T(108)T(109)T(110)T(111)T(112)T(113)T(114)T(115)T(116)T(117)T(118)T(119)T(120)T(121)T(122)T(123)T(124)T(125)T(126)T(127) \
T(128)T(129)T(130)T(131)T(132)T(133)T(134)T(135)T(136)T(137)T(138)T(139)T(140)T(141)T(142)T(143)T(144)T(145)T(146)T(147)T(148)T(149)T(150)T(151)T(152)T(153)T(154)T(155)T(156)T(157)T(158)T(159) \
T(160)T(161)T(162)T(163)T(164)T(165)T(166)T(167)T(168)T(169)T(170)T(171)T(172)T(173)T(174)T(175)T(176)T(177)T(178)T(179)T(180)T(181)T(182)T(183)T(184)T(185)T(186)T(187)T(188)T(189)T(190)T(191) \
T(192)T(193)T(194)T(195)T(196)T(197)T(198)T(199)T(200)T(201)T(202)T(203)T(204)T(205)T(206)T(207)T(208)T(209)T(210)T(211)T(212)T(213)T(214)T(215)T(216)T(217)T(218)T(219)T(220)T(221)T(222)T(223) \
T(224)T(225)T(226)T(227)T(228)T(229)T(230)T(231)T(232)T(233)T(234)T(235)T(236)T(237)T(238)T(239)T(240)T(241)T(242)T(243)T(244)T(245)T(246)T(247)T(248)T(249)T(250)T(251)T(252)T(253)T(254)T(255)

Definition at line 700 of file magic_enum.hpp.

◆ MAGIC_ENUM_RANGE_MAX

#define MAGIC_ENUM_RANGE_MAX   127

Definition at line 106 of file magic_enum.hpp.

◆ MAGIC_ENUM_RANGE_MIN

#define MAGIC_ENUM_RANGE_MIN   -128

Definition at line 100 of file magic_enum.hpp.

◆ MAGIC_ENUM_V

#define MAGIC_ENUM_V (   O)
Value:
if constexpr ((I + O) < Size) { \
if constexpr (is_valid<E, ualue<E, Min, S>(I + O)>()) { \
valid[I + O] = true; \
++count; \
} \
}

◆ MAGIC_ENUM_VERSION_MAJOR

#define MAGIC_ENUM_VERSION_MAJOR   0

Definition at line 35 of file magic_enum.hpp.

◆ MAGIC_ENUM_VERSION_MINOR

#define MAGIC_ENUM_VERSION_MINOR   9

Definition at line 36 of file magic_enum.hpp.

◆ MAGIC_ENUM_VERSION_PATCH

#define MAGIC_ENUM_VERSION_PATCH   5

Definition at line 37 of file magic_enum.hpp.

lexy::count
constexpr auto count
Sink that counts all arguments.
Definition: fold.hpp:88
magic_enum::detail::is_valid
constexpr bool is_valid() noexcept
Definition: magic_enum.hpp:621


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:08