EnTT 3.14.0
Loading...
Searching...
No Matches
component.hpp
1#ifndef ENTT_ENTITY_COMPONENT_HPP
2#define ENTT_ENTITY_COMPONENT_HPP
3
4#include <cstddef>
5#include <type_traits>
6#include "../config/config.h"
7#include "fwd.hpp"
8
9namespace entt {
10
12namespace internal {
13
14template<typename Type, typename = void>
15struct in_place_delete: std::bool_constant<!(std::is_move_constructible_v<Type> && std::is_move_assignable_v<Type>)> {};
16
17template<>
18struct in_place_delete<void>: std::false_type {};
19
20template<typename Type>
21struct in_place_delete<Type, std::enable_if_t<Type::in_place_delete>>
22 : std::true_type {};
23
24template<typename Type, typename = void>
25struct page_size: std::integral_constant<std::size_t, !std::is_empty_v<ENTT_ETO_TYPE(Type)> * ENTT_PACKED_PAGE> {};
26
27template<>
28struct page_size<void>: std::integral_constant<std::size_t, 0u> {};
29
30template<typename Type>
31struct page_size<Type, std::void_t<decltype(Type::page_size)>>
32 : std::integral_constant<std::size_t, Type::page_size> {};
33
34} // namespace internal
41template<typename Type, typename = void>
43 static_assert(std::is_same_v<std::decay_t<Type>, Type>, "Unsupported type");
44
46 using type = Type;
47
49 static constexpr bool in_place_delete = internal::in_place_delete<Type>::value;
51 static constexpr std::size_t page_size = internal::page_size<Type>::value;
52};
53
54} // namespace entt
55
56#endif
EnTT default namespace.
Definition dense_map.hpp:22
Common way to access various properties of components.
Definition component.hpp:42
static constexpr std::size_t page_size
Page size, default is ENTT_PACKED_PAGE for non-empty types.
Definition component.hpp:51
static constexpr bool in_place_delete
Pointer stability, default is false.
Definition component.hpp:49
Type type
Component type.
Definition component.hpp:46