Thea
Classes | Public Types | Public Member Functions | List of all members
AlignedAllocator< T, N > Class Template Reference

Allocates aligned memory blocks. More...

#include <AlignedAllocator.hpp>

Classes

struct  rebind
 A structure that enables this allocator to allocate storage for objects of another type. More...
 

Public Types

typedef T const * const_pointer
 Const pointer to an allocated object/block. More...
 
typedef T const & const_reference
 Const reference to an allocated object. More...
 
typedef std::ptrdiff_t difference_type
 Type of difference of two pointers. More...
 
typedef T * pointer
 Pointer to an allocated object/block. More...
 
typedef T & reference
 Reference to an allocated object. More...
 
typedef std::size_t size_type
 Type of block sizes. More...
 
typedef T value_type
 Type of allocated objects. More...
 

Public Member Functions

pointer address (reference r)
 Get the address of a referenced object. More...
 
const_pointer address (const_reference r) const
 Get the address of a referenced object. More...
 
 AlignedAllocator () throw ()
 Default Constructor. More...
 
template<typename T2 >
 AlignedAllocator (AlignedAllocator< T2, N > const &) throw ()
 Copy constructor. More...
 
pointer allocate (size_type n)
 Allocate an aligned block of n bytes. More...
 
void construct (pointer p, const value_type &wert)
 Construct an object at a memory location. More...
 
void deallocate (pointer p, size_type n=0)
 Deallocate an aligned block. More...
 
void destroy (pointer p)
 Destroy an object at a memory location. More...
 
size_type max_size () const throw ()
 Get the maximum number of elements that can theoretically be allocated. More...
 
bool operator!= (const AlignedAllocator< T, N > &other) const
 Check if two allocators are different. More...
 
bool operator== (const AlignedAllocator< T, N > &other) const
 Check if two allocators are the same. More...
 
 ~AlignedAllocator () throw ()
 Destructor. More...
 

Detailed Description

template<typename T, size_t N = 16>
class Thea::AlignedAllocator< T, N >

Allocates aligned memory blocks.

Note
Currently only supports N = a power-of-two multiple of sizeof(void *) on Linux/macOS because of limitations of posix_memalign. Hence, N must be a minimum of 4 (32-bit) or 8 (64-bit) on such systems. On Windows, any power-of-two is supported.

From http://stackoverflow.com/a/8545389

Definition at line 38 of file AlignedAllocator.hpp.

Member Typedef Documentation

typedef T const* const_pointer

Const pointer to an allocated object/block.

Definition at line 46 of file AlignedAllocator.hpp.

typedef T const& const_reference

Const reference to an allocated object.

Definition at line 49 of file AlignedAllocator.hpp.

typedef std::ptrdiff_t difference_type

Type of difference of two pointers.

Definition at line 43 of file AlignedAllocator.hpp.

typedef T* pointer

Pointer to an allocated object/block.

Definition at line 45 of file AlignedAllocator.hpp.

typedef T& reference

Reference to an allocated object.

Definition at line 48 of file AlignedAllocator.hpp.

typedef std::size_t size_type

Type of block sizes.

Definition at line 42 of file AlignedAllocator.hpp.

typedef T value_type

Type of allocated objects.

Definition at line 41 of file AlignedAllocator.hpp.

Constructor & Destructor Documentation

AlignedAllocator ( )
throw (
)

Default Constructor.

Definition at line 53 of file AlignedAllocator.hpp.

AlignedAllocator ( AlignedAllocator< T2, N > const &  )
throw (
)

Copy constructor.

Definition at line 56 of file AlignedAllocator.hpp.

~AlignedAllocator ( )
throw (
)

Destructor.

Definition at line 59 of file AlignedAllocator.hpp.

Member Function Documentation

pointer address ( reference  r)

Get the address of a referenced object.

Definition at line 62 of file AlignedAllocator.hpp.

const_pointer address ( const_reference  r) const

Get the address of a referenced object.

Definition at line 65 of file AlignedAllocator.hpp.

pointer allocate ( size_type  n)

Allocate an aligned block of n bytes.

Definition at line 68 of file AlignedAllocator.hpp.

void construct ( pointer  p,
const value_type wert 
)

Construct an object at a memory location.

Definition at line 92 of file AlignedAllocator.hpp.

void deallocate ( pointer  p,
size_type  n = 0 
)

Deallocate an aligned block.

Definition at line 82 of file AlignedAllocator.hpp.

void destroy ( pointer  p)

Destroy an object at a memory location.

Definition at line 95 of file AlignedAllocator.hpp.

size_type max_size ( ) const
throw (
)

Get the maximum number of elements that can theoretically be allocated.

Definition at line 98 of file AlignedAllocator.hpp.

bool operator!= ( const AlignedAllocator< T, N > &  other) const

Check if two allocators are different.

Definition at line 108 of file AlignedAllocator.hpp.

bool operator== ( const AlignedAllocator< T, N > &  other) const

Check if two allocators are the same.

Returns true if and only if storage allocated from *this can be deallocated from other, and vice versa. Always returns true for stateless allocators like this one.

Definition at line 114 of file AlignedAllocator.hpp.


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