EnTT  3.10.0
ident.hpp
1 #ifndef ENTT_CORE_IDENT_HPP
2 #define ENTT_CORE_IDENT_HPP
3 
4 #include <cstddef>
5 #include <type_traits>
6 #include <utility>
7 #include "../config/config.h"
8 #include "fwd.hpp"
9 #include "type_traits.hpp"
10 
11 namespace entt {
12 
40 template<typename... Types>
41 class identifier {
42  template<typename Type, std::size_t... Index>
43  [[nodiscard]] static constexpr id_type get(std::index_sequence<Index...>) ENTT_NOEXCEPT {
44  static_assert((std::is_same_v<Type, Types> || ...), "Invalid type");
45  return (0 + ... + (std::is_same_v<Type, type_list_element_t<Index, type_list<std::decay_t<Types>...>>> ? id_type{Index} : id_type{}));
46  }
47 
48 public:
51 
53  template<typename Type>
54  static constexpr identifier_type type = get<std::decay_t<Type>>(std::index_sequence_for<Types...>{});
55 };
56 
57 } // namespace entt
58 
59 #endif
Types identifiers.
Definition: ident.hpp:41
id_type identifier_type
Unsigned integer type.
Definition: ident.hpp:50
static constexpr identifier_type type
Statically generated unique identifier for the given type.
Definition: ident.hpp:54
EnTT default namespace.
Definition: dense_map.hpp:22
std::uint32_t id_type
Alias declaration for type identifiers.
Definition: fwd.hpp:14
typename type_list_element< Index, List >::type type_list_element_t
Helper type.
A class to use to push around lists of types, nothing more.