EnTT 4.0.0
Loading...
Searching...
No Matches
component.hpp
1#ifndef ENTT_ENTITY_COMPONENT_HPP
2#define ENTT_ENTITY_COMPONENT_HPP
3
4#include "../config/config.h"
5#include "../core/concepts.hpp"
6#include "../stl/concepts.hpp"
7#include "../stl/cstddef.hpp"
8#include "../stl/type_traits.hpp"
9#include "fwd.hpp"
10
11namespace entt {
12
14namespace internal {
15
16template<typename Type>
17struct in_place_delete: stl::bool_constant<!(stl::is_move_constructible_v<Type> && stl::is_move_assignable_v<Type>)> {};
18
19template<>
20struct in_place_delete<void>: stl::false_type {};
21
22template<typename Type>
23requires Type::in_place_delete
24struct in_place_delete<Type>: stl::true_type {};
25
26template<typename Type>
27struct page_size: stl::integral_constant<stl::size_t, !stl::is_empty_v<ENTT_ETO_TYPE(Type)> * ENTT_PACKED_PAGE> {};
28
29template<>
30struct page_size<void>: stl::integral_constant<stl::size_t, 0u> {};
31
32template<typename Type>
33requires stl::is_convertible_v<decltype(Type::page_size), stl::size_t>
34struct page_size<Type>: stl::integral_constant<stl::size_t, Type::page_size> {};
35
36} // namespace internal
38
44template<cvref_unqualified Type, typename Entity>
47 using element_type = Type;
49 using entity_type = Entity;
50
52 static constexpr bool in_place_delete = internal::in_place_delete<Type>::value;
54 static constexpr stl::size_t page_size = internal::page_size<Type>::value;
55};
56
57} // namespace entt
58
59#endif
EnTT default namespace.
Definition dense_map.hpp:25
stl::integral_constant< decltype(Value), Value > integral_constant
Wraps a static constant.
Common way to access various properties of components.
Definition component.hpp:45
Entity entity_type
Underlying entity identifier.
Definition component.hpp:49
static constexpr stl::size_t page_size
Page size, default is ENTT_PACKED_PAGE for non-empty types.
Definition component.hpp:54
static constexpr bool in_place_delete
Pointer stability, default is false.
Definition component.hpp:52
Type element_type
Element type.
Definition component.hpp:47