EnTT: src/entt/core/ident.hpp Source File

EnTT 3.15.0

Loading...
Searching...
No Matches
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 "fwd.hpp"
8#include "type_traits.hpp"
9
10namespace entt {
11
16template<typename... Type>
17 class ident {
18 template<typename Curr, std::size_t... Index>
19 [[nodiscard]] static constexpr id_type get(std::index_sequence<Index...>) noexcept {
20 static_assert((std::is_same_v<Curr, Type> || ...), "Invalid type");
21 return (0 + ... + (std::is_same_v<Curr, type_list_element_t<Index, type_list<std::decay_t<Type>...>>> ? id_type{Index} : id_type{}));
22 }
23
24public:
26 using value_type = id_type;
27
29 template<typename Curr>
30 static constexpr value_type value = get<std::decay_t<Curr>>(std::index_sequence_for<Type...>{});
31};
32
33} // namespace entt
34
35#endif
entt::ident
Type integral identifiers.
Definition ident.hpp:17
entt::ident::value_type
id_type value_type
Unsigned integer type.
Definition ident.hpp:26
entt::ident::value
static constexpr value_type value
Statically generated unique identifier for the given type.
Definition ident.hpp:30
entt
EnTT default namespace.
Definition dense_map.hpp:22
entt::id_type
std::uint32_t id_type
Alias declaration for type identifiers.
Definition fwd.hpp:29
entt::get
constexpr get_t< Type... > get
Variable template for lists of observed elements.
Definition fwd.hpp:167
entt::type_list_element_t
typename type_list_element< Index, List >::type type_list_element_t
Helper type.
Definition type_traits.hpp:149
entt::type_list
A class to use to push around lists of types, nothing more.
Definition type_traits.hpp:111