EnTT: entt::basic_registry< Entity, Allocator > Class Template Reference

EnTT 3.16.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::basic_registry< Entity, Allocator > Class Template Reference

Fast and reliable entity-component system. More...

`#include <registry.hpp>`

## Public Types
using | allocator_type = Allocator
| Allocator type.
using | entity_type = typename traits_type::value_type
| Underlying entity identifier.
using | version_type = typename traits_type::version_type
| Underlying version type.
using | size_type = std::size_t
| Unsigned integer type.
using | common_type = base_type
| Common type among all storage types.
using | context = internal::registry_context<allocator_type>
| Context type.
using | iterable = iterable_adaptor<internal::registry_storage_iterator<typename pool_container_type::iterator>>
| Iterable registry type.
using | const_iterable = iterable_adaptor<internal::registry_storage_iterator<typename pool_container_type::const_iterator>>
| Constant iterable registry type.
template<typename Type>
using | storage_for_type = typename storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<std::remove_const_t<Type>>>::type

## Public Member Functions
| basic_registry ()
| Default constructor.
| basic_registry (const allocator_type &allocator)
| Constructs an empty registry with a given allocator.
| basic_registry (const size_type count, const allocator_type &allocator=allocator_type{})
| Allocates enough memory upon construction to store count pools.
| basic_registry (const basic_registry &)=delete
| Default copy constructor, deleted on purpose.
| basic_registry (basic_registry &&other) noexcept
| Move constructor.
| ~basic_registry ()=default
| Default destructor.
basic_registry & | operator= (const basic_registry &)=delete
| Default copy assignment operator, deleted on purpose.
basic_registry & | operator= (basic_registry &&other) noexcept
| Move assignment operator.
void | swap (basic_registry &other) noexcept
| Exchanges the contents with those of a given registry.
constexpr allocator_type | get_allocator () const noexcept
| Returns the associated allocator.
iterable | storage () noexcept
| Returns an iterable object to use to visit a registry.
const_iterable | storage () const noexcept
| Returns an iterable object to use to visit a registry.
common_type * | storage (const id_type id)
| Finds the storage associated with a given name, if any.
const common_type * | storage (const id_type id) const
| Finds the storage associated with a given name, if any.
template<typename Type>
storage_for_type< Type > & | storage (const id_type id=type_hash< Type >::value())
| Returns the storage for a given element type.
template<typename Type>
const storage_for_type< Type > * | storage (const id_type id=type_hash< Type >::value()) const
| Returns the storage for a given element type, if any.
bool | reset (const id_type id)
| Discards the storage associated with a given name, if any.
bool | valid (const entity_type entt) const
| Checks if an identifier refers to a valid entity.
version_type | current (const entity_type entt) const
| Returns the actual version for an identifier.
entity_type | create ()
| Creates a new entity or recycles a destroyed one.
entity_type | create (const entity_type hint)
| Creates a new entity or recycles a destroyed one.
template<typename It>
void | create (It first, It last)
| Assigns each element in a range an identifier.
version_type | destroy (const entity_type entt)
| Destroys an entity and releases its identifier.
version_type | destroy (const entity_type entt, const version_type version)
| Destroys an entity and releases its identifier.
template<typename It>
void | destroy (It first, It last)
| Destroys all entities in a range and releases their identifiers.
template<typename Type, typename... Args>
decltype(auto) | emplace (const entity_type entt, Args &&...args)
| Assigns the given element to an entity.
template<typename Type, typename It>
void | insert (It first, It last)
| Assigns each entity in a range the given element.
template<typename Type, typename It>
void | insert (It first, It last, const Type &value)
| Assigns each entity in a range the given element.
template<typename Type, typename EIt, typename CIt, typename = std::enable_if_t<std::is_same_v<typename std::iterator_traits<CIt>::value_type, Type>>>
void | insert (EIt first, EIt last, CIt from)
| Assigns each entity in a range the given elements.
template<typename Type, typename... Args>
decltype(auto) | emplace_or_replace (const entity_type entt, Args &&...args)
| Assigns or replaces the given element for an entity.
template<typename Type, typename... Func>
decltype(auto) | patch (const entity_type entt, Func &&...func)
| Patches the given element for an entity.
template<typename Type, typename... Args>
decltype(auto) | replace (const entity_type entt, Args &&...args)
| Replaces the given element for an entity.
template<typename Type, typename... Other>
size_type | remove (const entity_type entt)
| Removes the given elements from an entity.
template<typename Type, typename... Other, typename It>
size_type | remove (It first, It last)
| Removes the given elements from all the entities in a range.
template<typename Type, typename... Other>
void | erase (const entity_type entt)
| Erases the given elements from an entity.
template<typename Type, typename... Other, typename It>
void | erase (It first, It last)
| Erases the given elements from all the entities in a range.
template<typename Func>
void | erase_if (const entity_type entt, Func func)
| Erases elements satisfying specific criteria from an entity.
template<typename... Type>
void | compact ()
| Removes all tombstones from a registry or only the pools for the given elements.
template<typename... Type>
bool | all_of (const entity_type entt) const
| Check if an entity is part of all the given storage.
template<typename... Type>
bool | any_of (const entity_type entt) const
| Check if an entity is part of at least one given storage.
template<typename... Type>
decltype(auto) | get (const entity_type entt) const
| Returns references to the given elements for an entity.
template<typename... Type>
decltype(auto) | get (const entity_type entt)
| Returns references to the given elements for an entity.
template<typename Type, typename... Args>
decltype(auto) | get_or_emplace (const entity_type entt, Args &&...args)
| Returns a reference to the given element for an entity.
template<typename... Type>
auto | try_get (const entity_type entt) const
| Returns pointers to the given elements for an entity.
template<typename... Type>
auto | try_get (const entity_type entt)
| Returns pointers to the given elements for an entity.
template<typename... Type>
void | clear ()
| Clears a whole registry or the pools for the given elements.
bool | orphan (const entity_type entt) const
| Checks if an entity has elements assigned.
template<typename Type>
auto | on_construct (const id_type id=type_hash< Type >::value())
| Returns a sink object for the given element.
template<typename Type>
auto | on_update (const id_type id=type_hash< Type >::value())
| Returns a sink object for the given element.
template<typename Type>
auto | on_destroy (const id_type id=type_hash< Type >::value())
| Returns a sink object for the given element.
template<typename Type, typename... Other, typename... Exclude>
basic_view< get_t< storage_for_type< const Type >, storage_for_type< const Other >... >, exclude_t< storage_for_type< const Exclude >... > > | view (exclude_t< Exclude... >=exclude_t{}) const
| Returns a view for the given elements.
template<typename Type, typename... Other, typename... Exclude>
basic_view< get_t< storage_for_type< Type >, storage_for_type< Other >... >, exclude_t< storage_for_type< Exclude >... > > | view (exclude_t< Exclude... >=exclude_t{})
| Returns a view for the given elements.
template<typename... Owned, typename... Get, typename... Exclude>
basic_group< owned_t< storage_for_type< Owned >... >, get_t< storage_for_type< Get >... >, exclude_t< storage_for_type< Exclude >... > > | group (get_t< Get... >=get_t{}, exclude_t< Exclude... >=exclude_t{})
| Returns a group for the given elements.
template<typename... Owned, typename... Get, typename... Exclude>
basic_group< owned_t< storage_for_type< const Owned >... >, get_t< storage_for_type< const Get >... >, exclude_t< storage_for_type< const Exclude >... > > | group_if_exists (get_t< Get... >=get_t{}, exclude_t< Exclude... >=exclude_t{}) const
| Returns a group for the given elements.
template<typename... Type>
bool | owned () const
| Checks whether the given elements belong to any group.
template<typename Type, typename Compare, typename Sort = std_sort, typename... Args>
void | sort (Compare compare, Sort algo=Sort{}, Args &&...args)
| Sorts the elements of a given element.
template<typename To, typename From>
void | sort ()
| Sorts two pools of elements in the same way.
context & | ctx () noexcept
| Returns the context object, that is, a general purpose container.
const context & | ctx () const noexcept
| Returns the context object, that is, a general purpose container.

## Detailed Description

template<typename Entity, typename Allocator>
class entt::basic_registry< Entity, Allocator >

Fast and reliable entity-component system.

Template Parameters

  Entity | A valid entity type.
  Allocator | Type of allocator used to manage memory and elements.

Definition at line 238 of file registry.hpp.

## Member Typedef Documentation

## ◆ allocator_type

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::allocator_type = Allocator

Allocator type.

Definition at line 306 of file registry.hpp.

## ◆ common_type

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::common_type = base_type

Common type among all storage types.

Definition at line 314 of file registry.hpp.

## ◆ const_iterable

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::const_iterable = iterable_adaptor<internal::registry_storage_iterator<typename pool_container_type::const_iterator>>

Constant iterable registry type.

Definition at line 320 of file registry.hpp.

## ◆ context

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::context = internal::registry_context<allocator_type>

Context type.

Definition at line 316 of file registry.hpp.

## ◆ entity_type

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::entity_type = typename traits_type::value_type

Underlying entity identifier.

Definition at line 308 of file registry.hpp.

## ◆ iterable

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::iterable = iterable_adaptor<internal::registry_storage_iterator<typename pool_container_type::iterator>>

Iterable registry type.

Definition at line 318 of file registry.hpp.

## ◆ size_type

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::size_type = std::size_t

Unsigned integer type.

Definition at line 312 of file registry.hpp.

## ◆ storage_for_type

template<typename Entity, typename Allocator>
template<typename Type>

using entt::basic_registry< Entity, Allocator >::storage_for_type = typename storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<std::remove_const_t<Type>>>::type

Template Parameters

  Type | Storage value type, eventually const.

Definition at line 327 of file registry.hpp.

## ◆ version_type

template<typename Entity, typename Allocator>

using entt::basic_registry< Entity, Allocator >::version_type = typename traits_type::version_type

Underlying version type.

Definition at line 310 of file registry.hpp.

## Constructor & Destructor Documentation

## ◆ basic_registry() [1/4]

template<typename Entity, typename Allocator>

entt::basic_registry< Entity, Allocator >::basic_registry | ( |  | ) |
| inline

Default constructor.

Definition at line 330 of file registry.hpp.

## ◆ basic_registry() [2/4]

template<typename Entity, typename Allocator>

entt::basic_registry< Entity, Allocator >::basic_registry | ( | const allocator_type & | allocator | ) |
| inlineexplicit

Constructs an empty registry with a given allocator.

Parameters

  allocator | The allocator to use.

Definition at line 337 of file registry.hpp.

## ◆ basic_registry() [3/4]

template<typename Entity, typename Allocator>

entt::basic_registry< Entity, Allocator >::basic_registry | ( | const size_type | count,
|  | const allocator_type & | allocator = allocator_type{} )
| inline

Allocates enough memory upon construction to store count pools.

Parameters

  count | The number of pools to allocate memory for.
  allocator | The allocator to use.

Definition at line 345 of file registry.hpp.

## ◆ basic_registry() [4/4]

template<typename Entity, typename Allocator>

entt::basic_registry< Entity, Allocator >::basic_registry | ( | basic_registry< Entity, Allocator > && | other | ) |
| inlinenoexcept

Move constructor.

Parameters

  other | The instance to move from.

Definition at line 361 of file registry.hpp.

## Member Function Documentation

## ◆ all_of()

template<typename Entity, typename Allocator>
template<typename... Type>

bool entt::basic_registry< Entity, Allocator >::all_of | ( | const entity_type | entt | ) | const
| inlinenodiscard

Check if an entity is part of all the given storage.

Template Parameters

  Type | Type of storage to check for.

Parameters

  entt | A valid identifier.

Returns
  True if the entity is part of all the storage, false otherwise.

Definition at line 872 of file registry.hpp.

## ◆ any_of()

template<typename Entity, typename Allocator>
template<typename... Type>

bool entt::basic_registry< Entity, Allocator >::any_of | ( | const entity_type | entt | ) | const
| inlinenodiscard

Check if an entity is part of at least one given storage.

Template Parameters

  Type | Type of storage to check for.

Parameters

  entt | A valid identifier.

Returns
  True if the entity is part of at least one storage, false otherwise.

Definition at line 889 of file registry.hpp.

## ◆ clear()

template<typename Entity, typename Allocator>
template<typename... Type>

void entt::basic_registry< Entity, Allocator >::clear | ( |  | ) |
| inline

Clears a whole registry or the pools for the given elements.

Template Parameters

  Type | Types of elements to remove from their entities.

Definition at line 980 of file registry.hpp.

## ◆ compact()

template<typename Entity, typename Allocator>
template<typename... Type>

void entt::basic_registry< Entity, Allocator >::compact | ( |  | ) |
| inline

Removes all tombstones from a registry or only the pools for the given elements.

Template Parameters

  Type | Types of elements for which to clear all tombstones.

Definition at line 855 of file registry.hpp.

## ◆ create() [1/3]

template<typename Entity, typename Allocator>

entity_type entt::basic_registry< Entity, Allocator >::create | ( |  | ) |
| inlinenodiscard

Creates a new entity or recycles a destroyed one.

Returns
  A valid identifier.

Definition at line 503 of file registry.hpp.

## ◆ create() [2/3]

template<typename Entity, typename Allocator>

entity_type entt::basic_registry< Entity, Allocator >::create | ( | const entity_type | hint | ) |
| inlinenodiscard

Creates a new entity or recycles a destroyed one.

If the requested entity isn't in use, the suggested identifier is used. Otherwise, a new identifier is generated.

Parameters

  hint | Required identifier.

Returns
  A valid identifier.

Definition at line 516 of file registry.hpp.

## ◆ create() [3/3]

template<typename Entity, typename Allocator>
template<typename It>

void entt::basic_registry< Entity, Allocator >::create | ( | It | first,
|  | It | last )
| inline

Assigns each element in a range an identifier.

See also
  create

Template Parameters

  It | Type of forward iterator.

Parameters

  first | An iterator to the first element of the range to generate.
  last | An iterator past the last element of the range to generate.

Definition at line 530 of file registry.hpp.

## ◆ ctx() [1/2]

template<typename Entity, typename Allocator>

const context & entt::basic_registry< Entity, Allocator >::ctx | ( |  | ) | const
| inlinenodiscardnoexcept

Returns the context object, that is, a general purpose container.

Returns
  The context object, that is, a general purpose container.

Definition at line 1226 of file registry.hpp.

## ◆ ctx() [2/2]

template<typename Entity, typename Allocator>

context & entt::basic_registry< Entity, Allocator >::ctx | ( |  | ) |
| inlinenodiscardnoexcept

Returns the context object, that is, a general purpose container.

Returns
  The context object, that is, a general purpose container.

Definition at line 1221 of file registry.hpp.

## ◆ current()

template<typename Entity, typename Allocator>

version_type entt::basic_registry< Entity, Allocator >::current | ( | const entity_type | entt | ) | const
| inlinenodiscard

Returns the actual version for an identifier.

Parameters

  entt | A valid identifier.

Returns
  The version for the given identifier if valid, the tombstone version otherwise.

Definition at line 495 of file registry.hpp.

## ◆ destroy() [1/3]

template<typename Entity, typename Allocator>

version_type entt::basic_registry< Entity, Allocator >::destroy | ( | const entity_type | entt | ) |
| inline

Destroys an entity and releases its identifier.

Warning
  Adding or removing elements to an entity that is being destroyed can result in undefined behavior.

Parameters

  entt | A valid identifier.

Returns
  The version of the recycled entity.

Definition at line 544 of file registry.hpp.

## ◆ destroy() [2/3]

template<typename Entity, typename Allocator>

version_type entt::basic_registry< Entity, Allocator >::destroy | ( | const entity_type | entt,
|  | const version_type | version )
| inline

Destroys an entity and releases its identifier.

The suggested version or the valid version closest to the suggested one is used instead of the implicitly generated version.

See also
  destroy

Parameters

  entt | A valid identifier.
  version | A desired version upon destruction.

Returns
  The version actually assigned to the entity.

Definition at line 565 of file registry.hpp.

## ◆ destroy() [3/3]

template<typename Entity, typename Allocator>
template<typename It>

void entt::basic_registry< Entity, Allocator >::destroy | ( | It | first,
|  | It | last )
| inline

Destroys all entities in a range and releases their identifiers.

See also
  destroy

Template Parameters

  It | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.

Definition at line 581 of file registry.hpp.

## ◆ emplace()

template<typename Entity, typename Allocator>
template<typename Type, typename... Args>

decltype(auto) entt::basic_registry< Entity, Allocator >::emplace | ( | const entity_type | entt,
|  | Args &&... | args )
| inline

Assigns the given element to an entity.

The element must have a proper constructor or be of aggregate type.

Warning
  Attempting to assign an element to an entity that already owns it results in undefined behavior.

Template Parameters

  Type | Type of element to create.
  Args | Types of arguments to use to construct the element.

Parameters

  entt | A valid identifier.
  args | Parameters to use to initialize the element.

Returns
  A reference to the newly created element.

Definition at line 608 of file registry.hpp.

## ◆ emplace_or_replace()

template<typename Entity, typename Allocator>
template<typename Type, typename... Args>

decltype(auto) entt::basic_registry< Entity, Allocator >::emplace_or_replace | ( | const entity_type | entt,
|  | Args &&... | args )
| inline

Assigns or replaces the given element for an entity.

See also
  emplace
  replace

Template Parameters

  Type | Type of element to assign or replace.
  Args | Types of arguments to use to construct the element.

Parameters

  entt | A valid identifier.
  args | Parameters to use to initialize the element.

Returns
  A reference to the newly created element.

Definition at line 677 of file registry.hpp.

## ◆ erase() [1/2]

template<typename Entity, typename Allocator>
template<typename Type, typename... Other>

void entt::basic_registry< Entity, Allocator >::erase | ( | const entity_type | entt | ) |
| inline

Erases the given elements from an entity.

Warning
  Attempting to erase an element from an entity that doesn't own it results in undefined behavior.

Template Parameters

  Type | Types of elements to erase.
  Other | Other types of elements to erase.

Parameters

  entt | A valid identifier.

Definition at line 789 of file registry.hpp.

## ◆ erase() [2/2]

template<typename Entity, typename Allocator>
template<typename Type, typename... Other, typename It>

void entt::basic_registry< Entity, Allocator >::erase | ( | It | first,
|  | It | last )
| inline

Erases the given elements from all the entities in a range.

See also
  erase

Template Parameters

  Type | Types of elements to erase.
  Other | Other types of elements to erase.
  It | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.

Definition at line 805 of file registry.hpp.

## ◆ erase_if()

template<typename Entity, typename Allocator>
template<typename Func>

void entt::basic_registry< Entity, Allocator >::erase_if | ( | const entity_type | entt,
|  | Func | func )
| inline

Erases elements satisfying specific criteria from an entity.

The function type is equivalent to:

void(const id_type, typename basic_registry<Entity>::common_type &);
entt::basic_registry::common_type
base_type common_type
Common type among all storage types.
Definition registry.hpp:314
entt::id_type
std::uint32_t id_type
Alias declaration for type identifiers.
Definition fwd.hpp:29

Only storage where the entity exists are passed to the function.

Template Parameters

  Func | Type of the function object to invoke.

Parameters

  entt | A valid identifier.
  func | A valid function object.

Definition at line 841 of file registry.hpp.

## ◆ get() [1/2]

template<typename Entity, typename Allocator>
template<typename... Type>

decltype(auto) entt::basic_registry< Entity, Allocator >::get | ( | const entity_type | entt | ) |
| inlinenodiscard

Returns references to the given elements for an entity.

Warning
  Attempting to get an element from an entity that doesn't own it results in undefined behavior.

Template Parameters

  Type | Types of elements to get.

Parameters

  entt | A valid identifier.

Returns
  References to the elements owned by the entity.

Definition at line 915 of file registry.hpp.

## ◆ get() [2/2]

template<typename Entity, typename Allocator>
template<typename... Type>

decltype(auto) entt::basic_registry< Entity, Allocator >::get | ( | const entity_type | entt | ) | const
| inlinenodiscard

Returns references to the given elements for an entity.

Warning
  Attempting to get an element from an entity that doesn't own it results in undefined behavior.

Template Parameters

  Type | Types of elements to get.

Parameters

  entt | A valid identifier.

Returns
  References to the elements owned by the entity.

Definition at line 905 of file registry.hpp.

## ◆ get_allocator()

template<typename Entity, typename Allocator>

allocator_type entt::basic_registry< Entity, Allocator >::get_allocator | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the associated allocator.

Returns
  The associated allocator.

Definition at line 408 of file registry.hpp.

## ◆ get_or_emplace()

template<typename Entity, typename Allocator>
template<typename Type, typename... Args>

decltype(auto) entt::basic_registry< Entity, Allocator >::get_or_emplace | ( | const entity_type | entt,
|  | Args &&... | args )
| inlinenodiscard

Returns a reference to the given element for an entity.

In case the entity doesn't own the element, the parameters provided are used to construct it.

See also
  get
  emplace

Template Parameters

  Type | Type of element to get.
  Args | Types of arguments to use to construct the element.

Parameters

  entt | A valid identifier.
  args | Parameters to use to initialize the element.

Returns
  Reference to the element owned by the entity.

Definition at line 939 of file registry.hpp.

## ◆ group()

template<typename Entity, typename Allocator>
template<typename... Owned, typename... Get, typename... Exclude>

basic_group< owned_t< storage_for_type< Owned >... >, get_t< storage_for_type< Get >... >, exclude_t< storage_for_type< Exclude >... > > entt::basic_registry< Entity, Allocator >::group | ( | get_t< Get... > | = get_t{},
|  | exclude_t< Exclude... > | = exclude_t{} )
| inline

Returns a group for the given elements.

Template Parameters

  Owned | Types of storage owned by the group.
  Get | Types of storage observed by the group, if any.
  Exclude | Types of storage used to filter the group, if any.

Returns
  A newly created group.

Definition at line 1105 of file registry.hpp.

## ◆ group_if_exists()

template<typename Entity, typename Allocator>
template<typename... Owned, typename... Get, typename... Exclude>

basic_group< owned_t< storage_for_type< const Owned >... >, get_t< storage_for_type< const Get >... >, exclude_t< storage_for_type< const Exclude >... > > entt::basic_registry< Entity, Allocator >::group_if_exists | ( | get_t< Get... > | = get_t{},
|  | exclude_t< Exclude... > | = exclude_t{} ) const
| inlinenodiscard

Returns a group for the given elements.

Template Parameters

  Owned | Types of storage owned by the group.
  Get | Types of storage observed by the group, if any.
  Exclude | Types of storage used to filter the group, if any.

Returns
  A newly created group.

Definition at line 1129 of file registry.hpp.

## ◆ insert() [1/3]

template<typename Entity, typename Allocator>
template<typename Type, typename EIt, typename CIt, typename = std::enable_if_t<std::is_same_v<typename std::iterator_traits<CIt>::value_type, Type>>>

void entt::basic_registry< Entity, Allocator >::insert | ( | EIt | first,
|  | EIt | last,
|  | CIt | from )
| inline

Assigns each entity in a range the given elements.

See also
  emplace

Template Parameters

  Type | Type of element to create.
  EIt | Type of input iterator.
  CIt | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.
  from | An iterator to the first element of the range of elements.

Definition at line 659 of file registry.hpp.

## ◆ insert() [2/3]

template<typename Entity, typename Allocator>
template<typename Type, typename It>

void entt::basic_registry< Entity, Allocator >::insert | ( | It | first,
|  | It | last )
| inline

Assigns each entity in a range the given element.

See also
  emplace

Template Parameters

  Type | Type of element to create.
  It | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.

Definition at line 624 of file registry.hpp.

## ◆ insert() [3/3]

template<typename Entity, typename Allocator>
template<typename Type, typename It>

void entt::basic_registry< Entity, Allocator >::insert | ( | It | first,
|  | It | last,
|  | const Type & | value )
| inline

Assigns each entity in a range the given element.

See also
  emplace

Template Parameters

  Type | Type of element to create.
  It | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.
  value | An instance of the element to assign.

Definition at line 641 of file registry.hpp.

## ◆ on_construct()

template<typename Entity, typename Allocator>
template<typename Type>

auto entt::basic_registry< Entity, Allocator >::on_construct | ( | const id_type | id = type_hash<Type>::value() | ) |
| inlinenodiscard

Returns a sink object for the given element.

Use this function to receive notifications whenever a new instance of the given element is created and assigned to an entity.
The function type for a listener is equivalent to:

void(basic_registry<Entity> &, Entity);
entt::basic_registry::basic_registry
basic_registry()
Default constructor.
Definition registry.hpp:330

Listeners are invoked after assigning the element to the entity.

See also
  sink

Template Parameters

  Type | Type of element of which to get the sink.

Parameters

  id | Optional name used to map the storage within the registry.

Returns
  A temporary sink object.

Definition at line 1022 of file registry.hpp.

## ◆ on_destroy()

template<typename Entity, typename Allocator>
template<typename Type>

auto entt::basic_registry< Entity, Allocator >::on_destroy | ( | const id_type | id = type_hash<Type>::value() | ) |
| inlinenodiscard

Returns a sink object for the given element.

Use this function to receive notifications whenever an instance of the given element is removed from an entity and thus destroyed.
The function type for a listener is equivalent to:

void(basic_registry<Entity> &, Entity);

Listeners are invoked before removing the element from the entity.

See also
  sink

Template Parameters

  Type | Type of element of which to get the sink.

Parameters

  id | Optional name used to map the storage within the registry.

Returns
  A temporary sink object.

Definition at line 1070 of file registry.hpp.

## ◆ on_update()

template<typename Entity, typename Allocator>
template<typename Type>

auto entt::basic_registry< Entity, Allocator >::on_update | ( | const id_type | id = type_hash<Type>::value() | ) |
| inlinenodiscard

Returns a sink object for the given element.

Use this function to receive notifications whenever an instance of the given element is explicitly updated.
The function type for a listener is equivalent to:

void(basic_registry<Entity> &, Entity);

Listeners are invoked after updating the element.

See also
  sink

Template Parameters

  Type | Type of element of which to get the sink.

Parameters

  id | Optional name used to map the storage within the registry.

Returns
  A temporary sink object.

Definition at line 1046 of file registry.hpp.

## ◆ operator=() [1/2]

template<typename Entity, typename Allocator>

basic_registry & entt::basic_registry< Entity, Allocator >::operator= | ( | basic_registry< Entity, Allocator > && | other | ) |
| inlinenoexcept

Move assignment operator.

Parameters

  other | The instance to move from.

Returns
  This registry.

Definition at line 383 of file registry.hpp.

## ◆ operator=() [2/2]

template<typename Entity, typename Allocator>

basic_registry & entt::basic_registry< Entity, Allocator >::operator= | ( | const basic_registry< Entity, Allocator > & |  | ) |
| delete

Default copy assignment operator, deleted on purpose.

Returns
  This mixin.

## ◆ orphan()

template<typename Entity, typename Allocator>

bool entt::basic_registry< Entity, Allocator >::orphan | ( | const entity_type | entt | ) | const
| inlinenodiscard

Checks if an entity has elements assigned.

Parameters

  entt | A valid identifier.

Returns
  True if the entity has no elements assigned, false otherwise.

Definition at line 998 of file registry.hpp.

## ◆ owned()

template<typename Entity, typename Allocator>
template<typename... Type>

bool entt::basic_registry< Entity, Allocator >::owned | ( |  | ) | const
| inlinenodiscard

Checks whether the given elements belong to any group.

Template Parameters

  Type | Types of elements in which one is interested.

Returns
  True if the pools of the given elements are free, false otherwise.

Definition at line 1147 of file registry.hpp.

## ◆ patch()

template<typename Entity, typename Allocator>
template<typename Type, typename... Func>

decltype(auto) entt::basic_registry< Entity, Allocator >::patch | ( | const entity_type | entt,
|  | Func &&... | func )
| inline

Patches the given element for an entity.

The signature of the function should be equivalent to the following:

void(Type &);

Warning
  Attempting to patch an element of an entity that doesn't own it results in undefined behavior.

Template Parameters

  Type | Type of element to patch.
  Func | Types of the function objects to invoke.

Parameters

  entt | A valid identifier.
  func | Valid function objects.

Returns
  A reference to the patched element.

Definition at line 703 of file registry.hpp.

## ◆ remove() [1/2]

template<typename Entity, typename Allocator>
template<typename Type, typename... Other>

size_type entt::basic_registry< Entity, Allocator >::remove | ( | const entity_type | entt | ) |
| inline

Removes the given elements from an entity.

Template Parameters

  Type | Type of element to remove.
  Other | Other types of elements to remove.

Parameters

  entt | A valid identifier.

Returns
  The number of elements actually removed.

Definition at line 735 of file registry.hpp.

## ◆ remove() [2/2]

template<typename Entity, typename Allocator>
template<typename Type, typename... Other, typename It>

size_type entt::basic_registry< Entity, Allocator >::remove | ( | It | first,
|  | It | last )
| inline

Removes the given elements from all the entities in a range.

See also
  remove

Template Parameters

  Type | Type of element to remove.
  Other | Other types of elements to remove.
  It | Type of input iterator.

Parameters

  first | An iterator to the first element of the range of entities.
  last | An iterator past the last element of the range of entities.

Returns
  The number of elements actually removed.

Definition at line 752 of file registry.hpp.

## ◆ replace()

template<typename Entity, typename Allocator>
template<typename Type, typename... Args>

decltype(auto) entt::basic_registry< Entity, Allocator >::replace | ( | const entity_type | entt,
|  | Args &&... | args )
| inline

Replaces the given element for an entity.

The element must have a proper constructor or be of aggregate type.

Warning
  Attempting to replace an element of an entity that doesn't own it results in undefined behavior.

Template Parameters

  Type | Type of element to replace.
  Args | Types of arguments to use to construct the element.

Parameters

  entt | A valid identifier.
  args | Parameters to use to initialize the element.

Returns
  A reference to the element being replaced.

Definition at line 723 of file registry.hpp.

## ◆ reset()

template<typename Entity, typename Allocator>

bool entt::basic_registry< Entity, Allocator >::reset | ( | const id_type | id | ) |
| inline

Discards the storage associated with a given name, if any.

Parameters

  id | Name used to map the storage within the registry.

Returns
  True in case of success, false otherwise.

Definition at line 475 of file registry.hpp.

## ◆ sort() [1/2]

template<typename Entity, typename Allocator>
template<typename To, typename From>

void entt::basic_registry< Entity, Allocator >::sort | ( |  | ) |
| inline

Sorts two pools of elements in the same way.

Entities and elements in To which are part of both storage are sorted internally with the order they have in From. The others follow in no particular order.

Warning
  Pools of elements owned by a group cannot be sorted.

Template Parameters

  To | Type of elements to sort.
  From | Type of elements to use to sort.

Definition at line 1211 of file registry.hpp.

## ◆ sort() [2/2]

template<typename Entity, typename Allocator>
template<typename Type, typename Compare, typename Sort = std_sort, typename... Args>

void entt::basic_registry< Entity, Allocator >::sort | ( | Compare | compare,
|  | Sort | algo = Sort{},
|  | Args &&... | args )
| inline

Sorts the elements of a given element.

The comparison function object returns true if the first element is less than the second one, false otherwise. Its signature is also equivalent to one of the following:

bool(const Entity, const Entity);
bool(const Type &, const Type &);

Moreover, it shall induce a strict weak ordering on the values.
The sort function object offers an operator() that accepts:

- An iterator to the first element of the range to sort.
- An iterator past the last element of the range to sort.
- A comparison function object to use to compare the elements.

The comparison function object hasn't necessarily the type of the one passed along with the other parameters to this member function.

Warning
  Pools of elements owned by a group cannot be sorted.

Template Parameters

  Type | Type of elements to sort.
  Compare | Type of comparison function object.
  Sort | Type of sort function object.
  Args | Types of arguments to forward to the sort function object.

Parameters

  compare | A valid comparison function object.
  algo | A valid sort function object.
  args | Arguments to forward to the sort function object, if any.

Definition at line 1185 of file registry.hpp.

## ◆ storage() [1/6]

template<typename Entity, typename Allocator>

const_iterable entt::basic_registry< Entity, Allocator >::storage | ( |  | ) | const
| inlinenodiscardnoexcept

Returns an iterable object to use to visit a registry.

The iterable object returns a pair that contains the name and a reference to the current storage.

Returns
  An iterable object to use to visit the registry.

Definition at line 425 of file registry.hpp.

## ◆ storage() [2/6]

template<typename Entity, typename Allocator>

iterable entt::basic_registry< Entity, Allocator >::storage | ( |  | ) |
| inlinenodiscardnoexcept

Returns an iterable object to use to visit a registry.

The iterable object returns a pair that contains the name and a reference to the current storage.

Returns
  An iterable object to use to visit the registry.

Definition at line 420 of file registry.hpp.

## ◆ storage() [3/6]

template<typename Entity, typename Allocator>

common_type * entt::basic_registry< Entity, Allocator >::storage | ( | const id_type | id | ) |
| inlinenodiscard

Finds the storage associated with a given name, if any.

Parameters

  id | Name used to map the storage within the registry.

Returns
  A pointer to the storage if it exists, a null pointer otherwise.

Definition at line 434 of file registry.hpp.

## ◆ storage() [4/6]

template<typename Entity, typename Allocator>

const common_type * entt::basic_registry< Entity, Allocator >::storage | ( | const id_type | id | ) | const
| inlinenodiscard

Finds the storage associated with a given name, if any.

Parameters

  id | Name used to map the storage within the registry.

Returns
  A pointer to the storage if it exists, a null pointer otherwise.

Definition at line 443 of file registry.hpp.

## ◆ storage() [5/6]

template<typename Entity, typename Allocator>
template<typename Type>

storage_for_type< Type > & entt::basic_registry< Entity, Allocator >::storage | ( | const id_type | id = type_hash<Type>::value() | ) |
| inline

Returns the storage for a given element type.

Template Parameters

  Type | Type of element of which to return the storage.

Parameters

  id | Optional name used to map the storage within the registry.

Returns
  The storage for the given element type.

Definition at line 455 of file registry.hpp.

## ◆ storage() [6/6]

template<typename Entity, typename Allocator>
template<typename Type>

const storage_for_type< Type > * entt::basic_registry< Entity, Allocator >::storage | ( | const id_type | id = type_hash<Type>::value() | ) | const
| inlinenodiscard

Returns the storage for a given element type, if any.

Template Parameters

  Type | Type of element of which to return the storage.

Parameters

  id | Optional name used to map the storage within the registry.

Returns
  The storage for the given element type.

Definition at line 466 of file registry.hpp.

## ◆ swap()

template<typename Entity, typename Allocator>

void entt::basic_registry< Entity, Allocator >::swap | ( | basic_registry< Entity, Allocator > & | other | ) |
| inlinenoexcept

Exchanges the contents with those of a given registry.

Parameters

  other | Registry to exchange the content with.

Definition at line 392 of file registry.hpp.

## ◆ try_get() [1/2]

template<typename Entity, typename Allocator>
template<typename... Type>

auto entt::basic_registry< Entity, Allocator >::try_get | ( | const entity_type | entt | ) |
| inlinenodiscard

Returns pointers to the given elements for an entity.

Note
  The registry retains ownership of the pointed-to elements.

Template Parameters

  Type | Types of elements to get.

Parameters

  entt | A valid identifier.

Returns
  Pointers to the elements owned by the entity.

Definition at line 967 of file registry.hpp.

## ◆ try_get() [2/2]

template<typename Entity, typename Allocator>
template<typename... Type>

auto entt::basic_registry< Entity, Allocator >::try_get | ( | const entity_type | entt | ) | const
| inlinenodiscard

Returns pointers to the given elements for an entity.

Note
  The registry retains ownership of the pointed-to elements.

Template Parameters

  Type | Types of elements to get.

Parameters

  entt | A valid identifier.

Returns
  Pointers to the elements owned by the entity.

Definition at line 956 of file registry.hpp.

## ◆ valid()

template<typename Entity, typename Allocator>

bool entt::basic_registry< Entity, Allocator >::valid | ( | const entity_type | entt | ) | const
| inlinenodiscard

Checks if an identifier refers to a valid entity.

Parameters

  entt | An identifier, either valid or not.

Returns
  True if the identifier is valid, false otherwise.

Definition at line 485 of file registry.hpp.

## ◆ view() [1/2]

template<typename Entity, typename Allocator>
template<typename Type, typename... Other, typename... Exclude>

basic_view< get_t< storage_for_type< Type >, storage_for_type< Other >... >, exclude_t< storage_for_type< Exclude >... > > entt::basic_registry< Entity, Allocator >::view | ( | exclude_t< Exclude... > | = exclude_t{} | ) |
| inlinenodiscard

Returns a view for the given elements.

Template Parameters

  Type | Type of element used to construct the view.
  Other | Other types of elements used to construct the view.
  Exclude | Types of elements used to filter the view.

Returns
  A newly created view.

Definition at line 1092 of file registry.hpp.

## ◆ view() [2/2]

template<typename Entity, typename Allocator>
template<typename Type, typename... Other, typename... Exclude>

basic_view< get_t< storage_for_type< const Type >, storage_for_type< const Other >... >, exclude_t< storage_for_type< const Exclude >... > > entt::basic_registry< Entity, Allocator >::view | ( | exclude_t< Exclude... > | = exclude_t{} | ) | const
| inlinenodiscard

Returns a view for the given elements.

Template Parameters

  Type | Type of element used to construct the view.
  Other | Other types of elements used to construct the view.
  Exclude | Types of elements used to filter the view.

Returns
  A newly created view.

Definition at line 1083 of file registry.hpp.

The documentation for this class was generated from the following files:

- src/entt/entity/fwd.hpp
- src/entt/entity/registry.hpp