ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type > Class Template Reference

STL-style allocator wrapper for ArenaPoolAllocator. More...

#include <ArenaPoolSTLAllocator.h>

Inheritance diagram for SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >:
Collaboration diagram for SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >:

Classes

struct  rebind
 Standard STL allocator rebinder. More...
 

Public Types

typedef std::allocator< T > base
 
typedef base::value_type value_type
 Standard STL allocator typedefs. More...
 
typedef base::size_type size_type
 
typedef base::difference_type difference_type
 

Public Member Functions

 ArenaPoolSTLAllocator (size_t nblock=1000, const std::string &name="")
 Default constructor. More...
 
template<class U , class V >
 ArenaPoolSTLAllocator (const ArenaPoolSTLAllocator< U, V > &a)
 Constructor from another ArenaPoolSTLAllocator. More...
 
size_t nblock () const
 Return the hinted number of objects allocated per block. More...
 
const std::string & name () const
 Return the name of this allocator. More...
 
ArenaAllocatorBase::Stats stats () const
 Return the statistics block for this allocator. More...
 
const ArenaBlockAllocatorBasepoolptr () const
 Return a pointer to the underlying allocator (may be 0). More...
 

Static Public Member Functions

template<class CONT >
static ArenaNonConstPoolSTLAllocator< T > get_allocator (CONT &c)
 Return an allocator supporting non-const methods from a non-const container reference. More...
 

Public Attributes

elements
 STL member. More...
 

Private Attributes

size_t m_nblock
 Saved hinted number of objects per block. More...
 
std::string m_name
 Saved allocator name. More...
 
const ArenaBlockAllocatorBasem_poolptr
 Point at an underlying allocator from a different specialization. More...
 

Detailed Description

template<class T>
class SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >

STL-style allocator wrapper for ArenaPoolAllocator.

This is the specialization for the case of the vetoed type.

We want to allow calling the non-const allocator methods reset(), erase(), and reserve() only if the corresponding container is non-const. However, we can't really do that, since the get_allocator() method of containers is only const, and returns an allocator by value. So instead, we split up this class. ArenaPoolSTLAllocator holds a const pointer to the underlying allocator, and supports only the const methods on it. Then ArenaNonConstPoolSTLAllocator derives from it and implements the non-const methods. To get an instance of the latter class, call ArenaPoolSTLAllocator::get_allocator(c), where is the container — and must be non-const.

See the file-level comments for further details.

Definition at line 445 of file ArenaPoolSTLAllocator.h.

Member Typedef Documentation

◆ base

template<class T >
typedef std::allocator<T> SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::base

Definition at line 450 of file ArenaPoolSTLAllocator.h.

◆ difference_type

template<class T >
typedef base::difference_type SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::difference_type

Definition at line 455 of file ArenaPoolSTLAllocator.h.

◆ size_type

template<class T >
typedef base::size_type SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::size_type

Definition at line 454 of file ArenaPoolSTLAllocator.h.

◆ value_type

template<class T >
typedef base::value_type SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::value_type

Standard STL allocator typedefs.

Definition at line 453 of file ArenaPoolSTLAllocator.h.

Constructor & Destructor Documentation

◆ ArenaPoolSTLAllocator() [1/2]

template<class T >
SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::ArenaPoolSTLAllocator ( size_t  nblock = 1000,
const std::string &  name = "" 
)

Default constructor.

Parameters
nblockValue to set in the parameters structure for the number of elements to allocate per block.
nameValue to set in the parameters structure for the allocator name.

◆ ArenaPoolSTLAllocator() [2/2]

template<class T >
template<class U , class V >
SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::ArenaPoolSTLAllocator ( const ArenaPoolSTLAllocator< U, V > &  a)

Constructor from another ArenaPoolSTLAllocator.

The name and nblock parameters are copied, but the data are not.

Member Function Documentation

◆ get_allocator()

template<class T >
template<class CONT >
static ArenaNonConstPoolSTLAllocator<T> SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::get_allocator ( CONT &  c)
static

Return an allocator supporting non-const methods from a non-const container reference.

Parameters
cThe (non-const) container.

◆ name()

template<class T >
const std::string& SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::name ( ) const

Return the name of this allocator.

◆ nblock()

template<class T >
size_t SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::nblock ( ) const

Return the hinted number of objects allocated per block.

◆ poolptr()

template<class T >
const ArenaBlockAllocatorBase* SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::poolptr ( ) const

Return a pointer to the underlying allocator (may be 0).

◆ stats()

template<class T >
ArenaAllocatorBase::Stats SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::stats ( ) const

Return the statistics block for this allocator.

Member Data Documentation

◆ elements

T std::allocator< T >::elements
inherited

STL member.

◆ m_name

template<class T >
std::string SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::m_name
private

Saved allocator name.

Definition at line 526 of file ArenaPoolSTLAllocator.h.

◆ m_nblock

template<class T >
size_t SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::m_nblock
private

Saved hinted number of objects per block.

Definition at line 523 of file ArenaPoolSTLAllocator.h.

◆ m_poolptr

template<class T >
const ArenaBlockAllocatorBase* SG::ArenaPoolSTLAllocator< T, typename std::enable_if<!std::is_pointer_v< T >, T >::type >::m_poolptr
private

Point at an underlying allocator from a different specialization.

Definition at line 529 of file ArenaPoolSTLAllocator.h.


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