ECSTASY
All in the name
Loading...
Searching...
No Matches
util::Allocator< Base > Class Template Reference

#include <Allocator.hpp>

Collaboration diagram for util::Allocator< Base >:

Public Member Functions

template<std::derived_from< Base > T, typename... Args>
T & instanciate (Args &&...args)
 Instanciate a new instance of type T with lifetime attached to this lifetime.
 

Private Attributes

std::vector< std::unique_ptr< Base > > _instances
 

Detailed Description

template<typename Base>
class util::Allocator< Base >

Definition at line 27 of file Allocator.hpp.

Member Function Documentation

◆ instanciate()

template<typename Base >
template<std::derived_from< Base > T, typename... Args>
T & util::Allocator< Base >::instanciate ( Args &&...  args)
inline

Instanciate a new instance of type T with lifetime attached to this lifetime.

Template Parameters
TType of the new object.
ArgsArguments Types of the object constructor.
Parameters
[in]argsArguments to forward to the object constructor.
Returns
T& newly created object.
Author
Andréas Leroux (andre.nosp@m.as.l.nosp@m.eroux.nosp@m.@epi.nosp@m.tech..nosp@m.eu)
Since
1.0.0 (2022-10-24)

Definition at line 43 of file Allocator.hpp.

44 {
45 return dynamic_cast<T &>(*_instances.emplace_back(std::make_unique<T>(std::forward<Args>(args)...)).get());
46 }
std::vector< std::unique_ptr< Base > > _instances
Definition Allocator.hpp:49
T emplace_back(T... args)

Member Data Documentation

◆ _instances

template<typename Base >
std::vector<std::unique_ptr<Base> > util::Allocator< Base >::_instances
private

Definition at line 49 of file Allocator.hpp.


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