Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::AlignedAllocator< T, Alignment > Class Template Reference

An allocator that aligns memory blocks according to a specified alignment. More...

#include <aligned.h>

Classes

struct  rebind

Public Types

using value_type = T

Public Member Functions

 AlignedAllocator () noexcept=default
template<class U>
 AlignedAllocator (const AlignedAllocator< U, Alignment > &) noexcept
T * allocate (std::size_t n)
 Allocates a block of memory that can hold n elements of type T.
void deallocate (T *ptr, std::size_t) noexcept
 Deallocates a block of memory that was previously allocated by allocate.

Detailed Description

template<class T, std::size_t Alignment>
class momentum::AlignedAllocator< T, Alignment >

An allocator that aligns memory blocks according to a specified alignment.

The allocator is compatible with std::allocator and can be used in place of std::allocator in STL containers.

Template Parameters
TThe type of elements that the allocator will allocate.
AlignmentThe alignment for the allocated memory blocks.

Definition at line 162 of file aligned.h.

Member Typedef Documentation

◆ value_type

template<class T, std::size_t Alignment>
using momentum::AlignedAllocator< T, Alignment >::value_type = T

Definition at line 164 of file aligned.h.

Constructor & Destructor Documentation

◆ AlignedAllocator() [1/2]

template<class T, std::size_t Alignment>
momentum::AlignedAllocator< T, Alignment >::AlignedAllocator ( )
defaultnoexcept

◆ AlignedAllocator() [2/2]

template<class T, std::size_t Alignment>
template<class U>
momentum::AlignedAllocator< T, Alignment >::AlignedAllocator ( const AlignedAllocator< U, Alignment > & )
inlineexplicitnoexcept

Definition at line 169 of file aligned.h.

Member Function Documentation

◆ allocate()

template<class T, std::size_t Alignment>
T * momentum::AlignedAllocator< T, Alignment >::allocate ( std::size_t n)
inlinenodiscard

Allocates a block of memory that can hold n elements of type T.

Parameters
[in]nThe number of elements to allocate space for.
Returns
A pointer to the first byte of the allocated memory block.

Definition at line 175 of file aligned.h.

◆ deallocate()

template<class T, std::size_t Alignment>
void momentum::AlignedAllocator< T, Alignment >::deallocate ( T * ptr,
std::size_t  )
inlinenoexcept

Deallocates a block of memory that was previously allocated by allocate.

Parameters
[in]ptrA pointer to the first byte of the memory block to deallocate.
nThe number of elements in the block. Unused; included to match the std::allocator interface.

Definition at line 184 of file aligned.h.


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