nngn
Loading...
Searching...
No Matches
nngn::tagging_allocator< D, A > Class Template Reference

Generic implementation of a malloc(3)-style allocator with headers. More...

#include <tagging.h>

Inheritance diagram for nngn::tagging_allocator< D, A >:
Collaboration diagram for nngn::tagging_allocator< D, A >:

Classes

struct  rebind
 

Public Types

using block_type = typename D::block_type
 
using value_type = typename D::value_type
 
using pointer = value_type *
 
using allocator = typename std::allocator_traits< A >::template rebind_alloc< char >
 
using block_type = typename D::block_type
 
using value_type = typename D::value_type
 
using pointer = value_type *
 
using allocator = typename std::allocator_traits< A >::template rebind_alloc< char >
 

Public Member Functions

 tagging_allocator (void)=default
 
 tagging_allocator (const tagging_allocator &rhs)
 
tagging_allocatoroperator= (const tagging_allocator &rhs)
 
template<tagging_descriptor D1, typename A1 >
 tagging_allocator (const tagging_allocator< D1, A1 > &rhs)
 
 tagging_allocator (const allocator &a)
 
 tagging_allocator (tagging_allocator &&) noexcept=default
 
tagging_allocatoroperator= (tagging_allocator &&) noexcept=default
 
 ~tagging_allocator (void)=default
 
pointer allocate (std::size_t n) noexcept
 Allocates n objects (n.b.: only one header is added).
 
template<typename I >
requires (detail::has_typed_alloc<allocator, I>)
pointer allocate (std::size_t n, I i) noexcept
 Typed allocation (see nngn::tracking_allocator).
 
pointer reallocate (pointer p, std::size_t n) noexcept
 
void deallocate (pointer p, std::size_t n) noexcept
 
const allocatorget_allocator (void) const
 
 tagging_allocator (void)=default
 
 tagging_allocator (const tagging_allocator &rhs)
 
tagging_allocatoroperator= (const tagging_allocator &rhs)
 
template<tagging_descriptor D1, typename A1 >
 tagging_allocator (const tagging_allocator< D1, A1 > &rhs)
 
 tagging_allocator (const allocator &a)
 
 tagging_allocator (tagging_allocator &&) noexcept=default
 
tagging_allocatoroperator= (tagging_allocator &&) noexcept=default
 
 ~tagging_allocator (void)=default
 
pointer allocate (std::size_t n) noexcept
 Allocates n objects (n.b.: only one header is added).
 
template<typename I >
requires (detail::has_typed_alloc<allocator, I>)
pointer allocate (std::size_t n, I i) noexcept
 Typed allocation (see nngn::tracking_allocator).
 
pointer reallocate (pointer p, std::size_t n) noexcept
 
void deallocate (pointer p, std::size_t n) noexcept
 
const allocatorget_allocator (void) const
 
template<typename I >
auto allocate (std::size_t n, I i) noexcept -> pointer requires(detail::has_typed_alloc< allocator, I >)
 

Static Private Member Functions

static pointer to_ptr (char *p)
 
static char * raw_from_ptr (pointer p)
 
static auto alloc_size (std::size_t n)
 
static pointer to_ptr (char *p)
 
static char * raw_from_ptr (pointer p)
 
static auto alloc_size (std::size_t n)
 

Private Attributes

allocator alloc = {}
 

Detailed Description

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
class nngn::tagging_allocator< D, A >

Generic implementation of a malloc(3)-style allocator with headers.

Objects are allocated using T::block_type (e.g. nngn::alloc_block), meaning a header is added to each allocation. This tagging is transparent: after template instantiation, the interface deals only with T::block_type::value_type objects.

The following are conditionally supported based on whether they are supported in the upstream allocator A:

See also
nngn::tagging_descriptor
nngn::alloc_block

Member Typedef Documentation

◆ allocator [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::allocator = typename std::allocator_traits<A>::template rebind_alloc<char>

◆ allocator [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::allocator = typename std::allocator_traits<A>::template rebind_alloc<char>

◆ block_type [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::block_type = typename D::block_type

◆ block_type [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::block_type = typename D::block_type

◆ pointer [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::pointer = value_type*

◆ pointer [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::pointer = value_type*

◆ value_type [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::value_type = typename D::value_type

◆ value_type [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
using nngn::tagging_allocator< D, A >::value_type = typename D::value_type

Constructor & Destructor Documentation

◆ tagging_allocator() [1/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( void  )
default

◆ tagging_allocator() [2/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( const tagging_allocator< D, A > &  rhs)
inline

◆ tagging_allocator() [3/10]

template<tagging_descriptor D, typename A >
template<tagging_descriptor D1, typename A1 >
nngn::tagging_allocator< D, A >::tagging_allocator ( const tagging_allocator< D1, A1 > &  rhs)

◆ tagging_allocator() [4/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( const allocator a)
inlineexplicit

◆ tagging_allocator() [5/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( tagging_allocator< D, A > &&  )
defaultnoexcept

◆ ~tagging_allocator() [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::~tagging_allocator ( void  )
default

◆ tagging_allocator() [6/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( void  )
default

◆ tagging_allocator() [7/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( const tagging_allocator< D, A > &  rhs)
inline

◆ tagging_allocator() [8/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
template<tagging_descriptor D1, typename A1 >
nngn::tagging_allocator< D, A >::tagging_allocator ( const tagging_allocator< D1, A1 > &  rhs)

◆ tagging_allocator() [9/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( const allocator a)
inlineexplicit

◆ tagging_allocator() [10/10]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::tagging_allocator ( tagging_allocator< D, A > &&  )
defaultnoexcept

◆ ~tagging_allocator() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
nngn::tagging_allocator< D, A >::~tagging_allocator ( void  )
default

Member Function Documentation

◆ alloc_size() [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
static auto nngn::tagging_allocator< D, A >::alloc_size ( std::size_t  n)
inlinestaticprivate

◆ alloc_size() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
static auto nngn::tagging_allocator< D, A >::alloc_size ( std::size_t  n)
inlinestaticprivate

◆ allocate() [1/5]

template<tagging_descriptor D, typename A >
auto nngn::tagging_allocator< D, A >::allocate ( std::size_t  n)
noexcept

Allocates n objects (n.b.: only one header is added).

Here is the call graph for this function:

◆ allocate() [2/5]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
pointer nngn::tagging_allocator< D, A >::allocate ( std::size_t  n)
noexcept

Allocates n objects (n.b.: only one header is added).

◆ allocate() [3/5]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
template<typename I >
requires (detail::has_typed_alloc<allocator, I>)
pointer nngn::tagging_allocator< D, A >::allocate ( std::size_t  n,
i 
)
noexcept

Typed allocation (see nngn::tracking_allocator).

◆ allocate() [4/5]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
template<typename I >
requires (detail::has_typed_alloc<allocator, I>)
pointer nngn::tagging_allocator< D, A >::allocate ( std::size_t  n,
i 
)
noexcept

Typed allocation (see nngn::tracking_allocator).

◆ allocate() [5/5]

template<tagging_descriptor D, typename A >
template<typename I >
auto nngn::tagging_allocator< D, A >::allocate ( std::size_t  n,
i 
) -> pointer requires(detail::has_typed_alloc<allocator, I>)
noexcept
Here is the call graph for this function:

◆ deallocate() [1/2]

template<tagging_descriptor D, typename A >
void nngn::tagging_allocator< D, A >::deallocate ( pointer  p,
std::size_t  n 
)
noexcept

◆ deallocate() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
void nngn::tagging_allocator< D, A >::deallocate ( pointer  p,
std::size_t  n 
)
noexcept

◆ get_allocator() [1/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
const allocator & nngn::tagging_allocator< D, A >::get_allocator ( void  ) const
inline

◆ get_allocator() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
const allocator & nngn::tagging_allocator< D, A >::get_allocator ( void  ) const
inline

◆ operator=() [1/4]

template<tagging_descriptor D, typename A >
auto nngn::tagging_allocator< D, A >::operator= ( const tagging_allocator< D, A > &  rhs)

◆ operator=() [2/4]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
tagging_allocator & nngn::tagging_allocator< D, A >::operator= ( const tagging_allocator< D, A > &  rhs)

◆ operator=() [3/4]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
tagging_allocator & nngn::tagging_allocator< D, A >::operator= ( tagging_allocator< D, A > &&  )
defaultnoexcept

◆ operator=() [4/4]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
tagging_allocator & nngn::tagging_allocator< D, A >::operator= ( tagging_allocator< D, A > &&  )
defaultnoexcept

◆ raw_from_ptr() [1/2]

template<tagging_descriptor D, typename A >
char * nngn::tagging_allocator< D, A >::raw_from_ptr ( pointer  p)
staticprivate

◆ raw_from_ptr() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
static char * nngn::tagging_allocator< D, A >::raw_from_ptr ( pointer  p)
staticprivate

◆ reallocate() [1/2]

template<tagging_descriptor D, typename A >
requires (detail::has_realloc<A>)
auto nngn::tagging_allocator< D, A >::reallocate ( pointer  p,
std::size_t  n 
)
noexcept

◆ reallocate() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
pointer nngn::tagging_allocator< D, A >::reallocate ( pointer  p,
std::size_t  n 
)
noexcept

◆ to_ptr() [1/2]

template<tagging_descriptor D, typename A >
auto nngn::tagging_allocator< D, A >::to_ptr ( char *  p)
staticprivate
Here is the caller graph for this function:

◆ to_ptr() [2/2]

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
static pointer nngn::tagging_allocator< D, A >::to_ptr ( char *  p)
staticprivate

Member Data Documentation

◆ alloc

template<tagging_descriptor D, typename A = std::allocator<typename D::block_type::value_type>>
allocator nngn::tagging_allocator< D, A >::alloc = {}
private

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