Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
StdFactory< ALO > Class Template Reference

#include "lib/allocator-handle.hpp"

Description

template<class ALO>
class lib::allo::StdFactory< ALO >

< Concepts and Adaptors for custom memory management

TICKET #1366 : define Allocator Concepts here TODO the following Concepts can be expected here (with C++20)

  • Allocator : for the bare memory allocation
  • Factory : for object fabrication and disposal
  • Handle : a functor front-end to be dependency-injected Adapter to implement the Factory concept based on a std::allocator
    Template Parameters
    ALOa std::allocator instance or anything compliant to Allocator
    Note
    in addition to the abilities defined by the standard, this adapter strives to provide some kind of lateral leeway, attempting to create dedicated allocators for other types than the BaseType implied by the given ALO (standard-allocator).
    • this is possible if the rebound allocator can be constructed from the given base allocator
    • alternatively, an attempt will be made to default-construct the rebound allocator for the other type requested.
    Warning
    Both avenues for adaptation may fail, which could lead to compilation or runtime failure.
    Remarks
    deliberately this class inherits from the allocator, allowing to exploit empty-base-optimisation, since usage of monostate allocators is quite common.

Definition at line 87 of file allocator-handle.hpp.

Public Member Functions

 StdFactory (Allo allo=Allo{})
 Create an instance of the adapter factory, forwarding to the embedded standard conforming allocator for object creation and destruction and memory management.
 
template<class XALO >
bool constexpr operator== (StdFactory< XALO > const &o) const
 
template<class XALO >
bool constexpr operator!= (StdFactory< XALO > const &o) const
 
template<class TY , typename... ARGS>
TY * create (ARGS &&...args)
 create new element using the embedded allocator
 
template<class TY >
void dispose (TY *elm)
 destroy the given element and discard the associated memory
 

Private Types

using Allo = ALO
 
using AlloT = std::allocator_traits< Allo >
 
using BaseType = Allo::value_type
 

Private Member Functions

AllobaseAllocator ()
 
template<typename X >
auto adaptAllocator ()
 
template<class ALOT , typename... ARGS>
ALOT::pointer construct (ALOT::allocator_type &allo, ARGS &&...args)
 
template<class ALOT >
void destroy (ALOT::allocator_type &allo, ALOT::pointer elm)
 

Constructor & Destructor Documentation

◆ StdFactory()

template<class ALO >
StdFactory ( Allo  allo = Allo{})
inline

Create an instance of the adapter factory, forwarding to the embedded standard conforming allocator for object creation and destruction and memory management.

Parameters
allo(optional) instance of the C++ standard allocator used for delegation, will be default constructed if omitted.
Remarks
the adapted standard allocator is assumed to be either a copyable value object, or even a mono-state; in both cases, a dedicated manager instance residing »elsewhere« is referred, rendering all those front-end instances exchangeable.

Definition at line 142 of file allocator-handle.hpp.

Member Typedef Documentation

◆ Allo

template<class ALO >
using Allo = ALO
private

Definition at line 90 of file allocator-handle.hpp.

◆ AlloT

template<class ALO >
using AlloT = std::allocator_traits<Allo>
private

Definition at line 91 of file allocator-handle.hpp.

◆ BaseType

template<class ALO >
using BaseType = Allo::value_type
private

Definition at line 92 of file allocator-handle.hpp.

Member Function Documentation

◆ baseAllocator()

template<class ALO >
Allo & baseAllocator ( )
inlineprivate

Definition at line 94 of file allocator-handle.hpp.

Referenced by StdFactory< ALO >::adaptAllocator(), StdFactory< ALO >::create(), StdFactory< ALO >::dispose(), and StdFactory< ALO >::operator==().

+ Here is the caller graph for this function:

◆ adaptAllocator()

template<class ALO >
template<typename X >
auto adaptAllocator ( )
inlineprivate

Definition at line 98 of file allocator-handle.hpp.

References StdFactory< ALO >::baseAllocator().

+ Here is the call graph for this function:

◆ construct()

template<class ALO >
template<class ALOT , typename... ARGS>
ALOT::pointer construct ( ALOT::allocator_type &  allo,
ARGS &&...  args 
)
inlineprivate

Definition at line 109 of file allocator-handle.hpp.

◆ destroy()

template<class ALO >
template<class ALOT >
void destroy ( ALOT::allocator_type &  allo,
ALOT::pointer  elm 
)
inlineprivate

Definition at line 123 of file allocator-handle.hpp.

◆ operator==()

template<class ALO >
template<class XALO >
bool constexpr operator== ( StdFactory< XALO > const &  o) const
inlineconstexpr

Definition at line 147 of file allocator-handle.hpp.

References StdFactory< ALO >::baseAllocator().

+ Here is the call graph for this function:

◆ operator!=()

template<class ALO >
template<class XALO >
bool constexpr operator!= ( StdFactory< XALO > const &  o) const
inlineconstexpr

Definition at line 152 of file allocator-handle.hpp.

◆ create()

template<class ALO >
template<class TY , typename... ARGS>
TY * create ( ARGS &&...  args)
inline

create new element using the embedded allocator

Definition at line 162 of file allocator-handle.hpp.

References StdFactory< ALO >::baseAllocator().

+ Here is the call graph for this function:

◆ dispose()

template<class ALO >
template<class TY >
void dispose ( TY *  elm)
inline

destroy the given element and discard the associated memory

Definition at line 179 of file allocator-handle.hpp.

References StdFactory< ALO >::baseAllocator().

+ Here is the call graph for this function:
+ Inheritance diagram for StdFactory< ALO >:
+ Collaboration diagram for StdFactory< ALO >:

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