Crypto++  5.6.5
Free C++ class library of cryptographic schemes
Public Types | Public Member Functions | Static Public Attributes | List of all members
AllocatorBase< T > Class Template Reference

Base class for all allocators used by SecBlock. More...

+ Inheritance diagram for AllocatorBase< T >:

Public Types

typedef T value_type
 
typedef size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 

Public Member Functions

pointer address (reference r) const
 
const_pointer address (const_reference r) const
 
void construct (pointer p, const T &val)
 
void destroy (pointer p)
 
size_type max_size () const
 Returns the maximum number of elements the allocator can provide. More...
 
template<typename U , typename... Args>
void construct (U *ptr, Args &&... args)
 Constructs a new U using variadic arguments. More...
 
template<typename U >
void destroy (U *ptr)
 Destroys an U constructed with variadic arguments. More...
 

Static Public Attributes

static const size_type ELEMS_MAX = ...
 Returns the maximum number of elements the allocator can provide. More...
 

Detailed Description

template<class T>
class AllocatorBase< T >

Base class for all allocators used by SecBlock.

Template Parameters
Tthe class or type

Definition at line 28 of file secblock.h.

Member Function Documentation

◆ max_size()

template<class T>
size_type AllocatorBase< T >::max_size ( ) const
inline

Returns the maximum number of elements the allocator can provide.

Returns
the maximum number of elements the allocator can provide

Internally, preprocessor macros are used rather than std::numeric_limits because the latter is not a constexpr. Some compilers, like Clang, do not optimize it well under all circumstances. Compilers like GCC, ICC and MSVC appear to optimize it well in either form.

Definition at line 70 of file secblock.h.

◆ construct()

template<class T>
template<typename U , typename... Args>
void AllocatorBase< T >::construct ( U *  ptr,
Args &&...  args 
)
inline

Constructs a new U using variadic arguments.

Template Parameters
Uthe type to be forwarded
Argsthe arguments to be forwarded
Parameters
ptrpointer to type U
argsvariadic arguments

This is a C++11 feature. It is available when CRYPTOPP_CXX11_VARIADIC_TEMPLATES is defined. The define is controlled by compiler versions detected in config.h.

Definition at line 82 of file secblock.h.

◆ destroy()

template<class T>
template<typename U >
void AllocatorBase< T >::destroy ( U *  ptr)
inline

Destroys an U constructed with variadic arguments.

Template Parameters
Uthe type to be forwarded

This is a C++11 feature. It is available when CRYPTOPP_CXX11_VARIADIC_TEMPLATES is defined. The define is controlled by compiler versions detected in config.h.

Definition at line 89 of file secblock.h.

Member Data Documentation

◆ ELEMS_MAX

template<class T>
const size_type AllocatorBase< T >::ELEMS_MAX = ...
static

Returns the maximum number of elements the allocator can provide.

ELEMS_MAX is the maximum number of elements the Allocator can provide. The value of ELEMS_MAX is SIZE_MAX/sizeof(T). std::numeric_limits was avoided due to lack of constexpr-ness in C++03 and below.

Note
In C++03 and below ELEMS_MAX is a static data member of type size_type. In C++11 and above ELEMS_MAX is an enum inheriting from size_type. In both cases ELEMS_MAX can be used before objects are fully constructed, and it does not suffer the limitations of class methods like max_size.
See also
Issue 346/CVE-2016-9939
Since
Crypto++ 6.0

Definition at line 57 of file secblock.h.


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