25 template<
auto... KeyList>
28 static_assert(
have_same_type_v<KeyList...>,
"EnumKeySet: the non-type values Keys must have the same type");
30 using Key_t = std::common_type_t<
decltype(KeyList)...>;
31 static_assert(std::is_enum_v<Key_t>,
"EnumKeySet: the parameter pack Keys must have an enumerator type");
39 static constexpr bool CheckKey(
Key_t key) {
return ((key == KeyList) || ...); }
47 "EnumKeySet::Index<Key>(): passing the Key, which is not defined in the mapping sequence");
61 Underlying_t res{std::numeric_limits<Underlying_t>::min()};
62 return ((res = std::max(
static_cast<Underlying_t>(KeyList), res)), ...);
68 Underlying_t res{std::numeric_limits<Underlying_t>::max()};
69 return ((res = std::min(
static_cast<Underlying_t>(KeyList), res)), ...);
73 static constexpr size_t NofKeys() {
return sizeof...(KeyList); }
88 ((res[idx++] = KeyList), ...);
97 for (
auto& value : res) {
Different metaprogramming utilities (type traits) for CBM experiment.
A subset of some enumeration entries and rule for mapping them to a contiguous integral index.
static constexpr size_t Index()
Returns an index of the enumeration key, which is passed as a template parameter.
static constexpr Container_t kMapper
static constexpr size_t Index(Key_t key)
Returns an index of the enumeration key, which is passed as a parameter.
static constexpr auto InitializedKeysArray()
Returns initialized keys.
std::underlying_type_t< Key_t > Underlying_t
Underlying integral type of the enumerator.
static constexpr bool CheckKey(Key_t key)
Checks, if a key is provided within the Keys pack.
std::array< Key_t, NofKeys()> KeyContainer_t
static constexpr Underlying_t MinKey()
Returns minimal value of the keys.
static constexpr Underlying_t MaxKey()
Returns maximal value of the keys.
static constexpr size_t NofKeys()
Returns number of keys.
std::array< size_t, MapperSize()> Container_t
static constexpr size_t MapperSize()
Returns size of the mapper.
static constexpr KeyContainer_t kKeys
static constexpr auto InitializedMapper()
Returns the initialized mapper.
std::common_type_t< decltype(KeyList)... > Key_t
Type of the keys.
constexpr bool have_same_type_v
Checks, if non-type parameter pack has the same type.
constexpr bool is_in_sequence_v