Lumiera  0.pre.03
»edit your freedom«
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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. More...
 
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
 
template<class XALO >
bool constexpr operator!= (StdFactory< XALO > const &o) const
 
template<class XALO >
bool constexpr operator== (StdFactory< XALO > const &o) const
 

Private Types

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

Private Member Functions

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

Constructor & Destructor Documentation

◆ StdFactory()

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.

+ Inheritance diagram for StdFactory< ALO >:
+ Collaboration diagram for StdFactory< ALO >:

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