15template <
typename T,
typename... Types>
17 constexpr bool matches[] = { std::is_same_v<T, Types>... };
19 for (std::size_t i = 0; i <
sizeof...(Types); ++i) {
20 if (matches[i])
return i;
23 return static_cast<std::size_t
>(-1);
27template <
typename T,
typename Variant>
30template <
typename T,
typename... Types>
34 static_assert(value !=
static_cast<std::size_t
>(-1),
35 "ERROR: The requested Event type is not part of the std::variant!");
39template <
typename T,
typename Variant>
43template <
typename T,
typename Variant>
46template <
typename T,
typename... Types>
48 static constexpr bool value = (std::is_same_v<T, Types> || ...);
52template <
typename T,
typename Variant>
57 static inline const char id = 0;
68template <
typename T,
typename =
void>
75 using type =
typename T::EventVariant;
constexpr bool has_variant_type_v
Compile-time boolean indicating if type T exists in Variant.
Definition VariantIndex.hpp:53
typename extract_event_variant< T >::type extract_event_variant_t
Definition VariantIndex.hpp:79
constexpr std::size_t get_variant_index_impl()
Definition VariantIndex.hpp:16
TypeIdPtr getTypeId() noexcept
Get static unique address for type T without dynamic allocations or RTTI.
Definition VariantIndex.hpp:64
const void * TypeIdPtr
Definition VariantIndex.hpp:60
constexpr std::size_t variant_index_v
Compile-time constant of type T's index in Variant.
Definition VariantIndex.hpp:40
Definition Application.hpp:16
Definition VariantIndex.hpp:56
Helper trait to check if type T exists inside std::variant<Types...> at compile time.
Definition VariantIndex.hpp:44
Helper trait to compute index of type T inside std::variant<Types...> at compile time.
Definition VariantIndex.hpp:28