Blaze 3.9
Classes | Public Types | List of all members
blaze::NullAllocator< T > Class Template Reference

Allocator returning nullptr. More...

#include <NullAllocator.h>

Classes

struct  rebind
 Implementation of the NullAllocator rebind mechanism. More...
 

Public Types

using ValueType = T
 Type of the allocated values.
 
using SizeType = size_t
 Size type of the null allocator.
 
using DifferenceType = ptrdiff_t
 Difference type of the null allocator.
 
using value_type = ValueType
 Type of the allocated values.
 
using size_type = SizeType
 Size type of the null allocator.
 
using difference_type = DifferenceType
 Difference type of the null allocator.
 

Public Member Functions

Constructors
 NullAllocator ()=default
 
template<typename U >
 NullAllocator (const NullAllocator< U > &)
 Conversion constructor from different NullAllocator instances. More...
 
Allocation functions
T * allocate (size_t numObjects)
 Performs no memory allocation and returns nullptr. More...
 
void deallocate (T *ptr, size_t numObjects) noexcept
 Deallocation of memory. More...
 

Detailed Description

template<typename T>
class blaze::NullAllocator< T >

Allocator returning nullptr.

The NullAllocator class template represents an implementation of the allocator concept of the standard library and acts as a stand-in for situation where no memory allocation is required. The NullAllocator will never allocate any memory and will always return nullptr.

Constructor & Destructor Documentation

◆ NullAllocator()

template<typename T >
template<typename U >
blaze::NullAllocator< T >::NullAllocator ( const NullAllocator< U > &  allocator)
inline

Conversion constructor from different NullAllocator instances.

Parameters
allocatorThe foreign null allocator to be copied.

Member Function Documentation

◆ allocate()

template<typename T >
T * blaze::NullAllocator< T >::allocate ( size_t  numObjects)
inline

Performs no memory allocation and returns nullptr.

Parameters
numObjectsThe number of objects to be allocated.
Returns
Pointer to the newly allocated memory.

This function does not perform any memory allocation and always returns nullptr.

◆ deallocate()

template<typename T >
void blaze::NullAllocator< T >::deallocate ( T *  ptr,
size_t  numObjects 
)
inlinenoexcept

Deallocation of memory.

Parameters
ptrThe address of the first element of the array to be deallocated.
numObjectsThe number of objects to be deallocated.
Returns
void

This function deallocates a junk of memory that was previously allocated via the allocate() function. Note that the argument numObjects must be equal ot the first argument of the call to allocate() that origianlly produced ptr.


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