1#ifndef ENTT_ENTITY_STORAGE_HPP
2#define ENTT_ENTITY_STORAGE_HPP
11#include "../config/config.h"
12#include "../core/iterator.hpp"
13#include "../core/memory.hpp"
14#include "../core/type_info.hpp"
15#include "component.hpp"
18#include "sparse_set.hpp"
29template<
typename Container, std::
size_t Size>
30class storage_iterator final {
31 friend storage_iterator<const Container, Size>;
33 using container_type = std::remove_const_t<Container>;
34 using alloc_traits = std::allocator_traits<typename container_type::allocator_type>;
36 using iterator_traits = std::iterator_traits<std::conditional_t<
37 std::is_const_v<Container>,
38 typename alloc_traits::template rebind_traits<typename std::pointer_traits<typename container_type::value_type>::element_type>::const_pointer,
39 typename alloc_traits::template rebind_traits<typename std::pointer_traits<typename container_type::value_type>::element_type>::pointer>>;
42 using value_type =
typename iterator_traits::value_type;
43 using pointer =
typename iterator_traits::pointer;
44 using reference =
typename iterator_traits::reference;
45 using difference_type =
typename iterator_traits::difference_type;
46 using iterator_category = std::random_access_iterator_tag;
48 constexpr storage_iterator() noexcept = default;
50 constexpr storage_iterator(Container *ref, const difference_type idx) noexcept
54 template<
bool Const = std::is_const_v<Container>,
typename = std::enable_if_t<Const>>
55 constexpr storage_iterator(
const storage_iterator<std::remove_const_t<Container>, Size> &other) noexcept
56 : storage_iterator{other.payload, other.offset} {}
58 constexpr storage_iterator &operator++() noexcept {
59 return --offset, *
this;
62 constexpr storage_iterator operator++(
int)
noexcept {
63 storage_iterator orig = *
this;
64 return ++(*this), orig;
67 constexpr storage_iterator &operator--() noexcept {
68 return ++offset, *
this;
71 constexpr storage_iterator operator--(
int)
noexcept {
72 storage_iterator orig = *
this;
73 return operator--(), orig;
76 constexpr storage_iterator &operator+=(
const difference_type value)
noexcept {
81 constexpr storage_iterator
operator+(
const difference_type value)
const noexcept {
82 storage_iterator copy = *
this;
83 return (copy += value);
86 constexpr storage_iterator &operator-=(
const difference_type value)
noexcept {
87 return (*
this += -value);
90 constexpr storage_iterator operator-(
const difference_type value)
const noexcept {
91 return (*
this + -value);
94 [[nodiscard]]
constexpr reference operator[](
const difference_type value)
const noexcept {
95 const auto pos = index() - value;
96 return (*payload)[pos / Size][
fast_mod(pos, Size)];
99 [[nodiscard]]
constexpr pointer operator->() const noexcept {
100 const auto pos = index();
101 return (*payload)[pos / Size] +
fast_mod(pos, Size);
104 [[nodiscard]]
constexpr reference operator*() const noexcept {
105 return *operator->();
108 [[nodiscard]]
constexpr difference_type index() const noexcept {
114 difference_type offset;
117template<
typename Lhs,
typename Rhs, std::
size_t Size>
118[[nodiscard]]
constexpr std::ptrdiff_t operator-(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
119 return rhs.index() - lhs.index();
122template<
typename Lhs,
typename Rhs, std::
size_t Size>
123[[nodiscard]]
constexpr bool operator==(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
124 return lhs.index() == rhs.index();
127template<
typename Lhs,
typename Rhs, std::
size_t Size>
128[[nodiscard]]
constexpr bool operator!=(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
129 return !(lhs == rhs);
132template<
typename Lhs,
typename Rhs, std::
size_t Size>
133[[nodiscard]]
constexpr bool operator<(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
134 return lhs.index() > rhs.index();
137template<
typename Lhs,
typename Rhs, std::
size_t Size>
138[[nodiscard]]
constexpr bool operator>(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
142template<
typename Lhs,
typename Rhs, std::
size_t Size>
143[[nodiscard]]
constexpr bool operator<=(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
147template<
typename Lhs,
typename Rhs, std::
size_t Size>
148[[nodiscard]]
constexpr bool operator>=(
const storage_iterator<Lhs, Size> &lhs,
const storage_iterator<Rhs, Size> &rhs)
noexcept {
152template<
typename It,
typename... Other>
153class extended_storage_iterator final {
154 template<
typename Iter,
typename... Args>
155 friend class extended_storage_iterator;
158 using iterator_type = It;
159 using difference_type = std::ptrdiff_t;
160 using value_type =
decltype(std::tuple_cat(std::make_tuple(*std::declval<It>()), std::forward_as_tuple(*std::declval<Other>()...)));
161 using pointer = input_iterator_pointer<value_type>;
162 using reference = value_type;
163 using iterator_category = std::input_iterator_tag;
165 constexpr extended_storage_iterator()
168 constexpr extended_storage_iterator(It base, Other... other)
169 : it{base, other...} {}
171 template<
typename... Args,
typename = std::enable_if_t<(!std::is_same_v<Other, Args> && ...) && (std::is_constructible_v<Other, Args> && ...)>>
172 constexpr extended_storage_iterator(
const extended_storage_iterator<It, Args...> &other)
175 constexpr extended_storage_iterator &operator++() noexcept {
176 return ++std::get<It>(it), (++std::get<Other>(it), ...), *
this;
179 constexpr extended_storage_iterator operator++(
int)
noexcept {
180 extended_storage_iterator orig = *
this;
181 return ++(*this), orig;
184 [[nodiscard]]
constexpr pointer operator->() const noexcept {
188 [[nodiscard]]
constexpr reference operator*() const noexcept {
189 return {*std::get<It>(it), *std::get<Other>(it)...};
192 [[nodiscard]]
constexpr iterator_type base() const noexcept {
193 return std::get<It>(it);
196 template<
typename... Lhs,
typename... Rhs>
197 friend constexpr bool operator==(
const extended_storage_iterator<Lhs...> &,
const extended_storage_iterator<Rhs...> &)
noexcept;
200 std::tuple<It, Other...> it;
203template<
typename... Lhs,
typename... Rhs>
204[[nodiscard]]
constexpr bool operator==(
const extended_storage_iterator<Lhs...> &lhs,
const extended_storage_iterator<Rhs...> &rhs)
noexcept {
205 return std::get<0>(lhs.it) == std::get<0>(rhs.it);
208template<
typename... Lhs,
typename... Rhs>
209[[nodiscard]]
constexpr bool operator!=(
const extended_storage_iterator<Lhs...> &lhs,
const extended_storage_iterator<Rhs...> &rhs)
noexcept {
210 return !(lhs == rhs);
235template<
typename Type,
typename Entity,
typename Allocator,
typename>
237 using alloc_traits = std::allocator_traits<Allocator>;
238 static_assert(std::is_same_v<typename alloc_traits::value_type, Type>,
"Invalid value type");
239 using container_type = std::vector<typename alloc_traits::pointer, typename alloc_traits::template rebind_alloc<typename alloc_traits::pointer>>;
243 static constexpr bool is_pinned_type_v = !(std::is_move_constructible_v<Type> && std::is_move_assignable_v<Type>);
245 [[nodiscard]]
auto &element_at(
const std::size_t pos)
const {
249 auto assure_at_least(
const std::size_t pos) {
252 if(!(idx < payload.size())) {
253 auto curr = payload.size();
255 payload.resize(idx + 1u,
nullptr);
258 for(
const auto last = payload.size(); curr < last; ++curr) {
263 payload.resize(curr);
271 template<
typename... Args>
272 auto emplace_element(
const Entity
entt,
const bool force_back, Args &&...args) {
276 auto elem = assure_at_least(
static_cast<size_type>(it.index()));
287 void shrink_to_size(
const std::size_t sz) {
294 alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
297 alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
301 for(
auto pos = from, last = payload.size(); pos < last; ++pos) {
305 payload.resize(from);
309 const void *get_at(
const std::size_t pos)
const final {
310 return std::addressof(element_at(pos));
313 void swap_or_move([[maybe_unused]]
const std::size_t from, [[maybe_unused]]
const std::size_t to)
override {
315 ENTT_ASSERT((from + 1u) && !is_pinned_type_v,
"Pinned type");
317 if constexpr(!is_pinned_type_v) {
318 auto &elem = element_at(from);
321 if(base_type::operator[](to) ==
tombstone) {
324 alloc_traits::destroy(allocator, std::addressof(elem));
330 swap(elem, element_at(to));
340 void pop(underlying_iterator first, underlying_iterator last)
override {
347 alloc_traits::destroy(allocator, std::addressof(elem));
351 [[maybe_unused]]
auto unused = std::exchange(elem, std::move(other));
352 alloc_traits::destroy(allocator, std::addressof(other));
366 alloc_traits::destroy(allocator, std::addressof(element_at(
static_cast<size_type>(first.index()))));
370 alloc_traits::destroy(allocator, std::addressof(element_at(
static_cast<size_type>(first.index()))));
382 underlying_iterator
try_emplace([[maybe_unused]]
const Entity
entt, [[maybe_unused]]
const bool force_back,
const void *
value)
override {
384 if constexpr(std::is_copy_constructible_v<value_type>) {
390 if constexpr(std::is_default_constructible_v<value_type>) {
391 return emplace_element(
entt, force_back);
412 using pointer =
typename container_type::pointer;
414 using const_pointer =
typename alloc_traits::template rebind_traits<typename alloc_traits::const_pointer>::const_pointer;
416 using iterator = internal::storage_iterator<container_type, traits_type::page_size>;
418 using const_iterator = internal::storage_iterator<const container_type, traits_type::page_size>;
442 payload{allocator} {}
450 payload{std::move(other.payload)} {}
458 :
base_type{std::move(other), allocator},
459 payload{std::move(other.payload), allocator} {
460 ENTT_ASSERT(alloc_traits::is_always_equal::value || payload.get_allocator() == other.payload.get_allocator(),
"Copying a storage is not allowed");
474 ENTT_ASSERT(alloc_traits::is_always_equal::value || payload.get_allocator() == other.payload.get_allocator(),
"Copying a storage is not allowed");
478 payload = std::move(other.payload);
489 swap(payload, other.payload);
497 return payload.get_allocator();
511 assure_at_least(cap - 1u);
535 return payload.data();
540 return payload.data();
551 const auto pos =
static_cast<typename iterator::difference_type
>(
base_type::size());
562 const auto pos =
static_cast<typename iterator::difference_type
>(
base_type::size());
593 return std::make_reverse_iterator(
cend());
603 return std::make_reverse_iterator(
end());
612 return std::make_reverse_iterator(
cbegin());
622 return std::make_reverse_iterator(
begin());
650 return std::forward_as_tuple(
get(
entt));
655 return std::forward_as_tuple(
get(
entt));
670 template<
typename... Args>
672 if constexpr(std::is_aggregate_v<value_type> && (
sizeof...(Args) != 0u || !std::is_default_constructible_v<value_type>)) {
673 const auto it = emplace_element(
entt,
false, Type{std::forward<Args>(args)...});
674 return element_at(
static_cast<size_type>(it.index()));
676 const auto it = emplace_element(
entt,
false, std::forward<Args>(args)...);
677 return element_at(
static_cast<size_type>(it.index()));
688 template<
typename... Func>
691 auto &elem = element_at(idx);
692 (std::forward<Func>(func)(elem), ...);
710 template<
typename It>
712 for(; first != last; ++first) {
713 emplace_element(*first,
true,
value);
732 template<typename EIt, typename CIt, typename = std::enable_if_t<std::is_same_v<typename std::iterator_traits<CIt>::value_type,
value_type>>>
734 for(; first != last; ++first, ++from) {
735 emplace_element(*first,
true, *from);
775 container_type payload;
779template<
typename Type,
typename Entity,
typename Allocator>
780class basic_storage<Type, Entity, Allocator, std::enable_if_t<component_traits<Type>::page_size == 0u>>
781 :
public basic_sparse_set<Entity, typename std::allocator_traits<Allocator>::template rebind_alloc<Entity>> {
782 using alloc_traits = std::allocator_traits<Allocator>;
783 static_assert(std::is_same_v<typename alloc_traits::value_type, Type>,
"Invalid value type");
830 :
base_type{std::move(other), allocator} {}
885 template<
typename... Args>
896 template<
typename... Func>
899 (std::forward<Func>(func)(), ...);
909 template<
typename It,
typename... Args>
910 void insert(It first, It last, Args &&...) {
911 for(; first != last; ++first) {
954template<
typename Entity,
typename Allocator>
957 using alloc_traits = std::allocator_traits<Allocator>;
958 static_assert(std::is_same_v<typename alloc_traits::value_type, Entity>,
"Invalid value type");
963 auto entity_at(
const std::size_t pos)
const noexcept {
964 ENTT_ASSERT(pos < local_traits_type::to_entity(
null),
"Invalid element");
969 void swap_or_move([[maybe_unused]]
const std::size_t lhs, [[maybe_unused]]
const std::size_t rhs)
override {
970 ENTT_ASSERT(((lhs < length) + (rhs < length)) != 1u,
"Cross swapping is not supported");
979 void pop(underlying_iterator first, underlying_iterator last)
override {
980 for(; first != last; ++first) {
984 if(pos != --length) {
1002 underlying_iterator
try_emplace(
const Entity hint,
const bool,
const void *)
override {
1047 length{std::exchange(other.length,
size_type{})} {}
1055 :
base_type{std::move(other), allocator},
1056 length{std::exchange(other.length,
size_type{})} {}
1065 length = std::exchange(other.length,
size_type{});
1094 return std::tuple{};
1104 swap(length, other.length);
1131 }
else if(
const auto curr = local_traits_type::construct(local_traits_type::to_entity(hint),
base_type::current(hint)); curr ==
tombstone) {
1132 const auto pos =
static_cast<size_type>(local_traits_type::to_entity(hint));
1156 template<
typename... Func>
1159 (std::forward<Func>(func)(), ...);
1168 template<
typename It>
1170 for(
const auto sz =
base_type::size(); first != last && length != sz; ++first, ++length) {
1174 for(; first != last; ++first) {
1186 template<
typename It>
1190 for(; first != last; ++first, --len) {
1192 ENTT_ASSERT(pos < length,
"Invalid element");
1196 return (length - len);
typename Traits::entity_type entity_type
Underlying entity type.
Basic sparse set implementation.
void swap(basic_sparse_set &other)
Exchanges the contents with those of a given sparse set.
const_iterator cbegin() const noexcept
Returns an iterator to the beginning.
virtual basic_iterator try_emplace(const Entity entt, const bool force_back, const void *=nullptr)
Assigns an entity to a sparse set.
virtual void pop_all()
Erases all entities of a sparse set.
void swap_and_pop(const basic_iterator it)
Erases an entity from a sparse set.
iterator end() const noexcept
Returns an iterator to the end.
const_reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the beginning.
reverse_iterator rend() const noexcept
Returns a reverse iterator to the end.
basic_sparse_set & operator=(basic_sparse_set &&other) noexcept
Move assignment operator.
virtual void reserve(const size_type cap)
Increases the capacity of a sparse set.
size_type size() const noexcept
Returns the number of elements in a sparse set.
version_type bump(const entity_type entt)
Bump the version number of an entity.
virtual void shrink_to_fit()
Requests the removal of unused capacity.
virtual void pop(basic_iterator first, basic_iterator last)
Erases entities from a sparse set.
version_type current(const entity_type entt) const noexcept
Returns the contained version for an identifier.
bool contains(const entity_type entt) const noexcept
Checks if a sparse set contains an entity.
const_iterator cend() const noexcept
Returns an iterator to the end.
void in_place_pop(const basic_iterator it)
Erases an entity from a sparse set.
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the end.
constexpr allocator_type get_allocator() const noexcept
Returns the associated allocator.
const void * value(const entity_type entt) const noexcept
Returns the element assigned to an entity, if any.
entity_type operator[](const size_type pos) const noexcept
Returns the entity at specified location, without bounds checking.
internal::sparse_set_iterator< packed_container_type > basic_iterator
Random access iterator type.
entity_type at(const size_type pos) const noexcept
Returns the entity at specified location, with bounds checking.
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the beginning.
size_type index(const entity_type entt) const noexcept
Returns the position of an entity in a sparse set.
void swap_at(const std::size_t lhs, const std::size_t rhs)
Swaps two items at specific locations.
const_iterator begin() const noexcept
Returns an iterator to the beginning.
iterator find(const entity_type entt) const noexcept
Finds an entity.
const_reverse_iterable reach() const noexcept
Returns a reverse iterable object to use to visit a storage.
std::size_t size_type
Unsigned integer type.
void swap(basic_storage &other)
Exchanges the contents with those of a given storage.
Entity value_type
Type of the objects assigned to entities.
void get(const entity_type entt) const noexcept
Returns the object assigned to an entity, that is void.
void insert(It first, It last)
Assigns each element in a range an identifier.
Entity entity_type
Underlying entity identifier.
basic_storage(basic_storage &&other, const allocator_type &allocator) noexcept
Allocator-extended move constructor.
void pop_all() override
Erases all entities of a sparse set.
entity_type emplace(const entity_type hint)
Creates a new identifier or recycles a destroyed one.
underlying_iterator try_emplace(const Entity hint, const bool, const void *) override
Assigns an entity to a storage.
basic_storage & operator=(basic_storage &&other) noexcept
Move assignment operator.
reverse_iterable reach() noexcept
Returns a reverse iterable object to use to visit a storage.
const_iterable each() const noexcept
Returns an iterable object to use to visit a storage.
void pop(underlying_iterator first, underlying_iterator last) override
Erases entities from a storage.
basic_storage(const allocator_type &allocator)
Constructs an empty container with a given allocator.
Allocator allocator_type
Allocator type.
void in_use(const size_type len) noexcept
Sets the number of elements considered still in use.
basic_storage(basic_storage &&other) noexcept
Move constructor.
entity_type emplace()
Creates a new identifier or recycles a destroyed one.
iterable each() noexcept
Returns an iterable object to use to visit a storage.
size_type pack(It first, It last)
Makes all elements in a range contiguous.
void patch(const entity_type entt, Func &&...func)
Updates a given identifier.
basic_storage()
Default constructor.
size_type in_use() const noexcept
Returns the number of elements considered still in use.
std::tuple get_as_tuple(const entity_type entt) const noexcept
Returns an empty tuple.
basic_storage()
Default constructor.
void emplace(const entity_type entt, Args &&...)
Assigns an entity to a storage and constructs its object.
reverse_iterable reach() noexcept
Returns a reverse iterable object to use to visit a storage.
Type value_type
Type of the objects assigned to entities.
constexpr allocator_type get_allocator() const noexcept
Returns the associated allocator.
void get(const entity_type entt) const noexcept
Returns the object assigned to an entity, that is void.
basic_storage(basic_storage &&other) noexcept=default
Move constructor.
std::size_t size_type
Unsigned integer type.
basic_storage(const allocator_type &allocator)
Constructs an empty container with a given allocator.
Entity entity_type
Underlying entity identifier.
const_iterable each() const noexcept
Returns an iterable object to use to visit a storage.
Allocator allocator_type
Allocator type.
void patch(const entity_type entt, Func &&...func)
Updates the instance assigned to a given entity in-place.
basic_storage(basic_storage &&other, const allocator_type &allocator) noexcept
Allocator-extended move constructor.
std::tuple get_as_tuple(const entity_type entt) const noexcept
Returns an empty tuple.
iterable each() noexcept
Returns an iterable object to use to visit a storage.
basic_storage & operator=(basic_storage &&other) noexcept=default
Move assignment operator.
void insert(It first, It last, Args &&...)
Assigns entities to a storage.
const_reverse_iterable reach() const noexcept
Returns a reverse iterable object to use to visit a storage.
Basic storage implementation.
iterator end() noexcept
Returns an iterator to the end.
~basic_storage() override
Default destructor.
basic_storage()
Default constructor.
iterator insert(EIt first, EIt last, CIt from)
Assigns one or more entities to a storage and constructs their objects from a given range.
const_reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the beginning.
const_iterator end() const noexcept
Returns an iterator to the end.
const_pointer raw() const noexcept
Direct access to the array of objects.
void pop_all() override
Erases all entities of a storage.
basic_storage(basic_storage &&other) noexcept
Move constructor.
const value_type & get(const entity_type entt) const noexcept
Returns the object assigned to an entity.
const_iterator cend() const noexcept
Returns an iterator to the end.
size_type capacity() const noexcept override
Returns the number of elements that a storage has currently allocated space for.
constexpr allocator_type get_allocator() const noexcept
Returns the associated allocator.
typename alloc_traits::template rebind_traits< typename alloc_traits::const_pointer >::const_pointer const_pointer
Constant pointer type to contained elements.
const_iterable each() const noexcept
Returns an iterable object to use to visit a storage.
reverse_iterator rbegin() noexcept
Returns a reverse iterator to the beginning.
internal::storage_iterator< container_type, traits_type::page_size > iterator
Random access iterator type.
Type value_type
Type of the objects assigned to entities.
const_iterator begin() const noexcept
Returns an iterator to the beginning.
reverse_iterator rend() noexcept
Returns a reverse iterator to the end.
basic_storage & operator=(basic_storage &&other) noexcept
Move assignment operator.
Entity entity_type
Underlying entity identifier.
const_reverse_iterator rend() const noexcept
Returns a reverse iterator to the end.
underlying_iterator try_emplace(const Entity entt, const bool force_back, const void *value) override
Assigns an entity to a storage.
const_iterator cbegin() const noexcept
Returns an iterator to the beginning.
std::reverse_iterator< const_iterator > const_reverse_iterator
Constant reverse iterator type.
value_type & patch(const entity_type entt, Func &&...func)
Updates the instance assigned to a given entity in-place.
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator type.
std::size_t size_type
Unsigned integer type.
iterator insert(It first, It last, const value_type &value={})
Assigns one or more entities to a storage and constructs their objects from a given instance.
void pop(underlying_iterator first, underlying_iterator last) override
Erases entities from a storage.
typename container_type::pointer pointer
Pointer type to contained elements.
reverse_iterable reach() noexcept
Returns a reverse iterable object to use to visit a storage.
pointer raw() noexcept
Direct access to the array of objects.
std::tuple< value_type & > get_as_tuple(const entity_type entt) noexcept
Returns the object assigned to an entity as a tuple.
value_type & get(const entity_type entt) noexcept
Returns the object assigned to an entity.
const_reverse_iterator crend() const noexcept
Returns a reverse iterator to the end.
const_reverse_iterable reach() const noexcept
Returns a reverse iterable object to use to visit a storage.
iterable each() noexcept
Returns an iterable object to use to visit a storage.
void reserve(const size_type cap) override
Increases the capacity of a storage.
basic_storage(const allocator_type &allocator)
Constructs an empty storage with a given allocator.
value_type & emplace(const entity_type entt, Args &&...args)
Assigns an entity to a storage and constructs its object.
std::tuple< const value_type & > get_as_tuple(const entity_type entt) const noexcept
Returns the object assigned to an entity as a tuple.
void shrink_to_fit() override
Requests the removal of unused capacity.
void swap(basic_storage &other)
Exchanges the contents with those of a given storage.
const_reverse_iterator crbegin() const noexcept
Returns a reverse iterator to the beginning.
internal::storage_iterator< const container_type, traits_type::page_size > const_iterator
Constant random access iterator type.
basic_storage(basic_storage &&other, const allocator_type &allocator) noexcept
Allocator-extended move constructor.
iterator begin() noexcept
Returns an iterator to the beginning.
Allocator allocator_type
Allocator type.
constexpr null_t null
Compile-time constant for null entities.
constexpr tombstone_t tombstone
Compile-time constant for tombstone entities.
constexpr Type * uninitialized_construct_using_allocator(Type *value, const Allocator &allocator, Args &&...args)
Uses-allocator construction utility (waiting for C++20).
constexpr std::size_t fast_mod(const std::size_t value, const std::size_t mod) noexcept
Fast module utility function (powers of two only).
constexpr get_t< Type... > get
Variable template for lists of observed components.
constexpr bool operator<=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator<(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr type_list< Type..., Other... > operator+(type_list< Type... >, type_list< Other... >)
Concatenates multiple type lists.
deletion_policy
Storage deletion policy.
@ swap_and_pop
Swap-and-pop deletion policy.
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr bool operator>=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
const type_info & type_id() noexcept
Returns the type info object associated to a given type.
constexpr bool operator>(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
constexpr auto to_address(Type &&ptr) noexcept
Unwraps fancy pointers, does nothing otherwise (waiting for C++20).
constexpr bool operator==(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) noexcept
Compares two hashed strings.
Common way to access various properties of components.
static constexpr std::size_t page_size
Page size, default is ENTT_PACKED_PAGE for non-empty types.
static constexpr bool in_place_delete
Pointer stability, default is false.
Utility class to create an iterable object from a pair of iterators.