vSMC  v3.0.0
Scalable Monte Carlo
Classes | Public Types | Public Member Functions | List of all members
vsmc::Allocator< T, Alignment, Memory > Class Template Reference

Aligned allocator. More...

#include <vsmc/utility/aligned_memory.hpp>

Classes

class  rebind
 

Public Types

using const_pointer = const T *
 
using const_reference = typename std::add_lvalue_reference< const T >::type
 
using difference_type = std::ptrdiff_t
 
using is_always_equal = std::true_type
 
using pointer = T *
 
using reference = typename std::add_lvalue_reference< T >::type
 
using size_type = std::size_t
 
using value_type = T
 

Public Member Functions

 Allocator ()=default
 
 Allocator (const Allocator< T, Alignment, Memory > &)=default
 
 Allocator (Allocator< T, Alignment, Memory > &&)=default
 
template<typename U >
 Allocator (const Allocator< U, Alignment, Memory > &other)
 
template<typename U >
 Allocator (Allocator< U, Alignment, Memory > &&other)
 
pointer allocate (size_type n, const void *=nullptr)
 
template<typename U , typename Arg , typename... Args>
void constrct (U *ptr, Arg &&arg, Args &&...args)
 
template<typename U >
void construct (U *ptr)
 
void deallocate (pointer ptr, size_type=0) noexcept
 
Allocator< T, Alignment, Memory > & operator= (const Allocator< T, Alignment, Memory > &)=default
 
Allocator< T, Alignment, Memory > & operator= (Allocator< T, Alignment, Memory > &&)=default
 

Detailed Description

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
class vsmc::Allocator< T, Alignment, Memory >

Aligned allocator.

Template Parameters
TThe value type
AlignmentThe alignment requirement of memory, must be a power of two and no less than sizeof(void *).
MemoryThe memory management class. Must provides two static member functions, aligned_malloc and aligned_free. The member function aligned_malloc shall behave similar to std::malloc but take an additional argument as alignment requirement. It need to be able to handle any alignment that is a power of two, other than zero. It need to return a non-null pointer even if the size is zero. It shall only return a null pointer if it fails to allocated the memory. It shall not throw any exceptions. The member function aligned_free shall behave just like std::free. It shall be able to handle a null pointer as its input.

Definition at line 292 of file aligned_memory.hpp.

Member Typedef Documentation

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::const_pointer = const T *

Definition at line 306 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::const_reference = typename std::add_lvalue_reference<const T>::type

Definition at line 308 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::difference_type = std::ptrdiff_t

Definition at line 304 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::is_always_equal = std::true_type

Definition at line 309 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::pointer = T *

Definition at line 305 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::reference = typename std::add_lvalue_reference<T>::type

Definition at line 307 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::size_type = std::size_t

Definition at line 303 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
using vsmc::Allocator< T, Alignment, Memory >::value_type = T

Definition at line 302 of file aligned_memory.hpp.

Constructor & Destructor Documentation

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
vsmc::Allocator< T, Alignment, Memory >::Allocator ( )
default
template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
vsmc::Allocator< T, Alignment, Memory >::Allocator ( const Allocator< T, Alignment, Memory > &  )
default
template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
vsmc::Allocator< T, Alignment, Memory >::Allocator ( Allocator< T, Alignment, Memory > &&  )
default
template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
template<typename U >
vsmc::Allocator< T, Alignment, Memory >::Allocator ( const Allocator< U, Alignment, Memory > &  other)
inline

Definition at line 331 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
template<typename U >
vsmc::Allocator< T, Alignment, Memory >::Allocator ( Allocator< U, Alignment, Memory > &&  other)
inline

Definition at line 337 of file aligned_memory.hpp.

Member Function Documentation

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
pointer vsmc::Allocator< T, Alignment, Memory >::allocate ( size_type  n,
const void *  = nullptr 
)
inline

Definition at line 342 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
template<typename U , typename Arg , typename... Args>
void vsmc::Allocator< T, Alignment, Memory >::constrct ( U *  ptr,
Arg &&  arg,
Args &&...  args 
)
inline

Definition at line 372 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
template<typename U >
void vsmc::Allocator< T, Alignment, Memory >::construct ( U *  ptr)
inline

Definition at line 364 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
void vsmc::Allocator< T, Alignment, Memory >::deallocate ( pointer  ptr,
size_type  = 0 
)
inlinenoexcept

Definition at line 357 of file aligned_memory.hpp.

template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
Allocator<T, Alignment, Memory>& vsmc::Allocator< T, Alignment, Memory >::operator= ( const Allocator< T, Alignment, Memory > &  )
default
template<typename T, std::size_t Alignment = AlignmentTrait<T>::value, typename Memory = AlignedMemory>
Allocator<T, Alignment, Memory>& vsmc::Allocator< T, Alignment, Memory >::operator= ( Allocator< T, Alignment, Memory > &&  )
default