PhoenixHardware  0.2.0
Tools to get hardware information
Loading...
Searching...
No Matches
PAlignedAllocator< T > Struct Template Reference

Custom allocator to align memory of std::vector. More...

#include <PAlignedAllocator.h>

Public Types

typedef T value_type
 Value of the type of the current allocator (used by std::vector to avoid ambiguities if we use multiple template)
 

Public Member Functions

 PAlignedAllocator ()=default
 
template<class U>
constexpr PAlignedAllocator (const PAlignedAllocator< U > &) noexcept
 Copy constructor from U type.
 

Static Public Member Functions

static T * allocate (std::size_t n)
 Do the memory allocation.
 
static void deallocate (T *p, std::size_t n) noexcept
 Free the allocated memory.
 

Detailed Description

template<class T>
struct PAlignedAllocator< T >

Custom allocator to align memory of std::vector.

Definition at line 21 of file PAlignedAllocator.h.

Member Typedef Documentation

◆ value_type

template<class T>
typedef T PAlignedAllocator< T >::value_type

Value of the type of the current allocator (used by std::vector to avoid ambiguities if we use multiple template)

Definition at line 23 of file PAlignedAllocator.h.

Constructor & Destructor Documentation

◆ PAlignedAllocator() [1/2]

template<class T>
PAlignedAllocator< T >::PAlignedAllocator ( )
default

◆ PAlignedAllocator() [2/2]

template<class T>
template<class U>
PAlignedAllocator< T >::PAlignedAllocator ( const PAlignedAllocator< U > & )
inlineconstexprnoexcept

Copy constructor from U type.

Definition at line 28 of file PAlignedAllocator.h.

28{}

Member Function Documentation

◆ allocate()

template<class T>
static T * PAlignedAllocator< T >::allocate ( std::size_t n)
inlinestatic

Do the memory allocation.

Parameters
n: number of element to be allocated
Returns
pointer to the allocated memory This function is nodiscard, so return value cannot be ignored We have to remove nodiscard when we make it static (and it works with std::vector)

Definition at line 36 of file PAlignedAllocator.h.

36 {
39 }
41 if(p != NULL){
42 return p;
43 }
44 throw std::bad_alloc();
45 }
T * phoenix_template_alloc_aligned1d(size_t nbValue)
Do a template allcoation of a type.
Custom allocator to align memory of std::vector.

References phoenix_template_alloc_aligned1d().

+ Here is the call graph for this function:

◆ deallocate()

template<class T>
static void PAlignedAllocator< T >::deallocate ( T * p,
std::size_t n )
inlinestaticnoexcept

Free the allocated memory.

Parameters
p: pointer to be freed
n: number of element allocated in p

Definition at line 50 of file PAlignedAllocator.h.

50 {
52 }
void phoenix_freeAlignedVector(void *ptr)
Free the aligned vector.

References phoenix_freeAlignedVector().

+ Here is the call graph for this function:

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