ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
StdContMARecycling< T > Struct Template Reference

Description:

template<typename T>
struct alib::monomem::StdContMARecycling< T >

Implementation of std::allocator to be used with container types provided by the C++ standard library.

As the C+++ library's specification does not include details of the container class's implementation, this allocator uses type util::RTTRAllocator which detects node types automatically.

Attention
It can not be guaranteed that a certain, uncommon implementation of the C++ library allocates memory in a way that this allocator truly recycles objects, and - even if the authors of ALib are optimistic hat this type works with any implementation - it is recommended to use the alternative container types found in this ALib Module .
See also
For background information about monotonic memory allocation, recycling and the issues of C++ standard container types, see the Programmer's Manual of this ALib Module .
Template Parameters
TThe type of objects to be allocated.

Definition at line 399 of file stdcontainerma.hpp.

#include <stdcontainerma.hpp>

Inheritance diagram for StdContMARecycling< T >:
[legend]
Collaboration diagram for StdContMARecycling< T >:
[legend]

Public Field Index:

RTTRAllocatorrecycler
 

Public Method Index:

constexpr StdContMARecycling (const StdContMARecycling &) noexcept=default
 
constexpr StdContMARecycling (RTTRAllocator &pRecycler)
 
constexpr StdContMARecycling (StdContMARecycling &&) noexcept=default
 
template<typename TSibling >
 StdContMARecycling (TSibling &StdContMARecycling)
 
T * allocate (size_t n, const void *=nullptr)
 
void deallocate (T *p, std::size_t n)
 
template<typename U >
bool operator!= (const StdContMARecycling< U > &rhs) const noexcept
 
template<typename U >
bool operator== (const StdContMARecycling< U > &rhs) const noexcept
 
- Public Method Index: inherited from StdContainerMABase< T >
size_t max_size () const noexcept
 

Additional Inherited Members

- Public Type Index: inherited from StdContainerMABase< T >
using difference_type = ptrdiff_t
 Type definition as required by C++ library standards.
 
using is_always_equal = std::false_type
 Type definition as required by C++ library standards.
 
using size_type = size_t
 Type definition as required by C++ library standards.
 
using value_type = T
 Type definition as required by C++ library standards.
 

Field Details:

◆ recycler

template<typename T >
RTTRAllocator& recycler

The only member of this allocator type used to perform all duties.

Definition at line 405 of file stdcontainerma.hpp.

Constructor(s) / Destructor Details::

◆ StdContMARecycling() [1/4]

template<typename T >
constexpr StdContMARecycling ( const StdContMARecycling< T > & )
constexprdefaultnoexcept

Defaulted copy constructor

◆ StdContMARecycling() [2/4]

template<typename T >
constexpr StdContMARecycling ( StdContMARecycling< T > && )
constexprdefaultnoexcept

Defaulted move constructor

◆ StdContMARecycling() [3/4]

template<typename T >
template<typename TSibling >
StdContMARecycling ( TSibling & StdContMARecycling)
inline

Copy constructor using an instance of different template type.

Template Parameters
TSiblingThe originating allocator's type (StdContMARecycling<X>).
Parameters
StdContMARecyclingThe originating allocator of type TSibling .

Definition at line 422 of file stdcontainerma.hpp.

◆ StdContMARecycling() [4/4]

template<typename T >
constexpr StdContMARecycling ( RTTRAllocator & pRecycler)
inlineconstexpr

Constructor for the initial allocator instantiation.

Parameters
pRecyclerThe recycler to for allocations and de-allocations.

Definition at line 430 of file stdcontainerma.hpp.

Method Details:

◆ allocate()

template<typename T >
T * allocate ( size_t n,
const void * = nullptr )
inline

Implementation of std::allocator interface. Dependent on whether a single or multiple objects are requested, this method invokes either RTTRAllocator::Get or RTTRAllocator::AllocUnrelated on field recycler.

Parameters
nThe number of requested objects to allocate storage for.
Returns
Pointer to the first byte of a memory block suitably aligned and sufficient to hold an array of n objects of type T .

Definition at line 475 of file stdcontainerma.hpp.

Here is the call graph for this function:

◆ deallocate()

template<typename T >
void deallocate ( T * p,
std::size_t n )
inline

Implementation of std::allocator interface. Dependent on whether a single or multiple objects are de-allocated (parameter n ), this method invokes either RTTRAllocator::Recycle or RTTRAllocator::RecycleChunk on field recycler.

Parameters
pPointer to the object to deallocate.
nThe number of objects to de-allocate.

Definition at line 494 of file stdcontainerma.hpp.

Here is the call graph for this function:

◆ operator!=()

template<typename T >
template<typename U >
bool operator!= ( const StdContMARecycling< U > & rhs) const
inlinenoexcept

Comparison operator.

Template Parameters
UThe allocation type of the other allocator.
Parameters
rhsThe right hand side allocator.
Returns
false if this and rhs use the same recycler, true otherwise.

Definition at line 456 of file stdcontainerma.hpp.

◆ operator==()

template<typename T >
template<typename U >
bool operator== ( const StdContMARecycling< U > & rhs) const
inlinenoexcept

Comparison operator.

Template Parameters
UThe allocation type of the other allocator.
Parameters
rhsThe right hand side allocator.
Returns
true if this and rhs use the same recycler, false otherwise.

Definition at line 444 of file stdcontainerma.hpp.


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