VapourSynth-llvmexpr
Loading...
Searching...
No Matches
llvmexpr_enum_detail Namespace Reference

Functions

template<typename T, std::size_t N>
consteval bool is_valid_enum ()
template<typename T, std::size_t N = 1>
consteval std::size_t find_upper_bound ()
template<typename T, std::size_t Low, std::size_t High>
consteval std::size_t binary_search_count ()
template<typename T>
consteval std::size_t enum_count ()
template<typename T, std::size_t... Is>
consteval auto make_names_impl (std::index_sequence< Is... >)
template<typename T>
consteval auto make_names ()

Function Documentation

◆ binary_search_count()

template<typename T, std::size_t Low, std::size_t High>
std::size_t llvmexpr_enum_detail::binary_search_count ( )
consteval

Definition at line 82 of file EnumName.hpp.

82 {
83 if constexpr (High - Low <= 1) {
84 return is_valid_enum<T, Low>() ? High : Low;
85 } else {
86 constexpr std::size_t MID = Low + ((High - Low) / 2);
87 if constexpr (is_valid_enum<T, MID>()) {
89 } else {
91 }
92 }
93}
consteval bool is_valid_enum()
Definition EnumName.hpp:68
consteval std::size_t binary_search_count()
Definition EnumName.hpp:82

References binary_search_count(), and is_valid_enum().

Referenced by binary_search_count(), and enum_count().

◆ enum_count()

template<typename T>
std::size_t llvmexpr_enum_detail::enum_count ( )
consteval

Definition at line 95 of file EnumName.hpp.

95 {
96 constexpr std::size_t UPPER = find_upper_bound<T>();
97 return binary_search_count<T, UPPER / 2, UPPER>();
98}
consteval std::size_t find_upper_bound()
Definition EnumName.hpp:73

References binary_search_count(), and find_upper_bound().

Referenced by enum_max(), and make_names().

◆ find_upper_bound()

template<typename T, std::size_t N = 1>
std::size_t llvmexpr_enum_detail::find_upper_bound ( )
consteval

Definition at line 73 of file EnumName.hpp.

73 {
74 if constexpr (!is_valid_enum<T, N>()) {
75 return N;
76 } else {
78 }
79}

References find_upper_bound(), and is_valid_enum().

Referenced by enum_count(), and find_upper_bound().

◆ is_valid_enum()

template<typename T, std::size_t N>
bool llvmexpr_enum_detail::is_valid_enum ( )
consteval

Definition at line 68 of file EnumName.hpp.

68 {
69 return !enum_name<static_cast<T>(N)>().contains(")");
70}
consteval std::string_view enum_name()
Definition EnumName.hpp:57

References enum_name().

Referenced by binary_search_count(), and find_upper_bound().

◆ make_names()

template<typename T>
auto llvmexpr_enum_detail::make_names ( )
consteval

Definition at line 105 of file EnumName.hpp.

105 {
106 return make_names_impl<T>(std::make_index_sequence<enum_count<T>()>{});
107}
consteval auto make_names_impl(std::index_sequence< Is... >)
Definition EnumName.hpp:101
consteval std::size_t enum_count()
Definition EnumName.hpp:95

References enum_count(), and make_names_impl().

Referenced by enum_name().

◆ make_names_impl()

template<typename T, std::size_t... Is>
auto llvmexpr_enum_detail::make_names_impl ( std::index_sequence< Is... > )
consteval

Definition at line 101 of file EnumName.hpp.

101 {
102 return std::array{enum_name<static_cast<T>(Is)>()...};
103}

References enum_name().

Referenced by make_names().