lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds::AlignmentAllocator< T, N > Class Template Reference

Stateless allocator for standard containers that allocates with posix_memalign() at N-byte alignment (default 16). More...

#include <AlignmentAllocator.hh>

Classes

struct  rebind
 Gives the same allocator for element type T2 (as other). More...
 

Public Types

typedef T value_type
 Element type T.
 
typedef std::size_t size_type
 Size type (std::size_t).
 
typedef std::ptrdiff_t difference_type
 Pointer difference type (std::ptrdiff_t).
 
typedef T * pointer
 Pointer to T.
 
typedef const T * const_pointer
 Pointer to const T.
 
typedef T & reference
 Reference to T.
 
typedef const T & const_reference
 Reference to const T.
 

Public Member Functions

 AlignmentAllocator () throw ()
 Does nothing; empty body.
 
template<typename T2 >
 AlignmentAllocator (const AlignmentAllocator< T2, N > &) throw ()
 Converting constructor from an allocator of another element type; does nothing.
 
 ~AlignmentAllocator () throw ()
 Does nothing; empty body.
 
pointer address (reference r)
 Return the address of r.
 
const_pointer address (const_reference r) const
 Return the address of the const element r.
 
pointer allocate (size_type n)
 Return n elements of storage aligned to N bytes from posix_memalign(), or nullptr if it fails.
 
void deallocate (pointer p, size_type)
 Free p with free(); the size argument is not used.
 
void construct (pointer p, const value_type &wert)
 Copy-construct wert in place at p.
 
void destroy (pointer p)
 Call the destructor of the element at p.
 
size_type max_size () const throw ()
 Return the largest size_type value divided by the element size.
 
bool operator!= (const AlignmentAllocator< T, N > &other) const
 Return the negation of operator==, which is always true, so this always returns false.
 
bool operator== (const AlignmentAllocator< T, N > &other) const
 Always returns true, since the allocator holds no state (per the code comment).
 

Detailed Description

template<typename T, std::size_t N = 16>
class Pds::AlignmentAllocator< T, N >

Stateless allocator for standard containers that allocates with posix_memalign() at N-byte alignment (default 16).

Member Typedef Documentation

◆ const_pointer

template<typename T , std::size_t N = 16>
typedef const T* Pds::AlignmentAllocator< T, N >::const_pointer

Pointer to const T.

◆ const_reference

template<typename T , std::size_t N = 16>
typedef const T& Pds::AlignmentAllocator< T, N >::const_reference

Reference to const T.

◆ difference_type

template<typename T , std::size_t N = 16>
typedef std::ptrdiff_t Pds::AlignmentAllocator< T, N >::difference_type

Pointer difference type (std::ptrdiff_t).

◆ pointer

template<typename T , std::size_t N = 16>
typedef T* Pds::AlignmentAllocator< T, N >::pointer

Pointer to T.

◆ reference

template<typename T , std::size_t N = 16>
typedef T& Pds::AlignmentAllocator< T, N >::reference

Reference to T.

◆ size_type

template<typename T , std::size_t N = 16>
typedef std::size_t Pds::AlignmentAllocator< T, N >::size_type

Size type (std::size_t).

◆ value_type

template<typename T , std::size_t N = 16>
typedef T Pds::AlignmentAllocator< T, N >::value_type

Element type T.

Constructor & Destructor Documentation

◆ AlignmentAllocator() [1/2]

template<typename T , std::size_t N = 16>
Pds::AlignmentAllocator< T, N >::AlignmentAllocator ( )
throw (
)
inline

Does nothing; empty body.

◆ AlignmentAllocator() [2/2]

template<typename T , std::size_t N = 16>
template<typename T2 >
Pds::AlignmentAllocator< T, N >::AlignmentAllocator ( const AlignmentAllocator< T2, N > &  )
throw (
)
inline

Converting constructor from an allocator of another element type; does nothing.

◆ ~AlignmentAllocator()

template<typename T , std::size_t N = 16>
Pds::AlignmentAllocator< T, N >::~AlignmentAllocator ( )
throw (
)
inline

Does nothing; empty body.

Member Function Documentation

◆ address() [1/2]

template<typename T , std::size_t N = 16>
const_pointer Pds::AlignmentAllocator< T, N >::address ( const_reference  r) const
inline

Return the address of the const element r.

◆ address() [2/2]

template<typename T , std::size_t N = 16>
pointer Pds::AlignmentAllocator< T, N >::address ( reference  r)
inline

Return the address of r.

◆ allocate()

template<typename T , std::size_t N = 16>
pointer Pds::AlignmentAllocator< T, N >::allocate ( size_type  n)
inline

Return n elements of storage aligned to N bytes from posix_memalign(), or nullptr if it fails.

◆ construct()

template<typename T , std::size_t N = 16>
void Pds::AlignmentAllocator< T, N >::construct ( pointer  p,
const value_type &  wert 
)
inline

Copy-construct wert in place at p.

◆ deallocate()

template<typename T , std::size_t N = 16>
void Pds::AlignmentAllocator< T, N >::deallocate ( pointer  p,
size_type   
)
inline

Free p with free(); the size argument is not used.

◆ destroy()

template<typename T , std::size_t N = 16>
void Pds::AlignmentAllocator< T, N >::destroy ( pointer  p)
inline

Call the destructor of the element at p.

◆ max_size()

template<typename T , std::size_t N = 16>
size_type Pds::AlignmentAllocator< T, N >::max_size ( ) const
throw (
)
inline

Return the largest size_type value divided by the element size.

◆ operator!=()

template<typename T , std::size_t N = 16>
bool Pds::AlignmentAllocator< T, N >::operator!= ( const AlignmentAllocator< T, N > &  other) const
inline

Return the negation of operator==, which is always true, so this always returns false.

◆ operator==()

template<typename T , std::size_t N = 16>
bool Pds::AlignmentAllocator< T, N >::operator== ( const AlignmentAllocator< T, N > &  other) const
inline

Always returns true, since the allocator holds no state (per the code comment).


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