piranha  0.10
Public Types | Public Member Functions | List of all members
piranha::dynamic_aligning_allocator< T > Class Template Reference

Memory allocator with runtime alignment support. More...

#include <piranha/dynamic_aligning_allocator.hpp>

Inheritance diagram for piranha::dynamic_aligning_allocator< T >:
Inheritance graph
[legend]

Public Types

using value_type = T
 Value type of the allocator. More...
 
using size_type = std::size_t
 Size type.
 
using propagate_on_container_move_assignment = std::true_type
 Move assignment propagation. More...
 

Public Member Functions

 dynamic_aligning_allocator ()
 Default constructor. More...
 
 dynamic_aligning_allocator (const dynamic_aligning_allocator &)=default
 Defaulted copy constructor.
 
 dynamic_aligning_allocator (dynamic_aligning_allocator &&)=default
 Defaulted move constructor.
 
 dynamic_aligning_allocator (const std::size_t &alignment)
 Constructor from alignment value. More...
 
template<typename U >
 dynamic_aligning_allocator (const dynamic_aligning_allocator< U > &other)
 Converting copy constructor. More...
 
template<typename U >
 dynamic_aligning_allocator (dynamic_aligning_allocator< U > &&other)
 Converting move constructor. More...
 
 ~dynamic_aligning_allocator ()=default
 Defaulted destructor.
 
dynamic_aligning_allocatoroperator= (const dynamic_aligning_allocator &other)=default
 Copy assignment operator. More...
 
dynamic_aligning_allocatoroperator= (dynamic_aligning_allocator &&other)=default
 Move assignment operator. More...
 
constexpr size_type max_size () const
 Maximum allocatable size. More...
 
value_typeallocate (const size_type &size) const
 Allocation function. More...
 
void deallocate (value_type *ptr, const size_type &) const
 Deallocation function. More...
 
bool operator== (const dynamic_aligning_allocator &other) const
 Equality operator. More...
 
bool operator!= (const dynamic_aligning_allocator &other) const
 Inequality operator. More...
 
std::size_t alignment () const
 Alignment getter. More...
 

Detailed Description

template<typename T>
class piranha::dynamic_aligning_allocator< T >

Memory allocator with runtime alignment support.

This allocator can be used to allocate memory aligned to a specific boundary, specified at runtime. The alignment value is provided upon construction and it is stored as a member of the allocator object. The allocator is standard-compliant and can hence be used in standard containers.

Definition at line 50 of file dynamic_aligning_allocator.hpp.

Member Typedef Documentation

◆ propagate_on_container_move_assignment

template<typename T>
using piranha::dynamic_aligning_allocator< T >::propagate_on_container_move_assignment = std::true_type

Move assignment propagation.

This allocator has to be move assigned when the container using it is move assigned.

Definition at line 64 of file dynamic_aligning_allocator.hpp.

◆ value_type

template<typename T>
using piranha::dynamic_aligning_allocator< T >::value_type = T

Value type of the allocator.

Alias for T.

Definition at line 57 of file dynamic_aligning_allocator.hpp.

Constructor & Destructor Documentation

◆ dynamic_aligning_allocator() [1/4]

template<typename T>
piranha::dynamic_aligning_allocator< T >::dynamic_aligning_allocator ( )
inline

Default constructor.

Will set the internal alignment value to zero.

Definition at line 69 of file dynamic_aligning_allocator.hpp.

◆ dynamic_aligning_allocator() [2/4]

template<typename T>
piranha::dynamic_aligning_allocator< T >::dynamic_aligning_allocator ( const std::size_t &  alignment)
inlineexplicit

Constructor from alignment value.

Parameters
alignmentalignment value that will be used for allocation.

Definition at line 80 of file dynamic_aligning_allocator.hpp.

◆ dynamic_aligning_allocator() [3/4]

template<typename T>
template<typename U >
piranha::dynamic_aligning_allocator< T >::dynamic_aligning_allocator ( const dynamic_aligning_allocator< U > &  other)
inlineexplicit

Converting copy constructor.

After construction, the alignment will be the same as other.

Parameters
otherconstruction argument.

Definition at line 90 of file dynamic_aligning_allocator.hpp.

◆ dynamic_aligning_allocator() [4/4]

template<typename T>
template<typename U >
piranha::dynamic_aligning_allocator< T >::dynamic_aligning_allocator ( dynamic_aligning_allocator< U > &&  other)
inlineexplicit

Converting move constructor.

After construction, the alignment will be the same as other.

Parameters
otherconstruction argument.

Definition at line 100 of file dynamic_aligning_allocator.hpp.

Member Function Documentation

◆ alignment()

template<typename T>
std::size_t piranha::dynamic_aligning_allocator< T >::alignment ( ) const
inline

Alignment getter.

Returns
the alignment value used for construction.

Definition at line 183 of file dynamic_aligning_allocator.hpp.

◆ allocate()

template<typename T>
value_type* piranha::dynamic_aligning_allocator< T >::allocate ( const size_type size) const
inline

Allocation function.

The allocation function is a thin wrapper around piranha::aligned_palloc().

Parameters
sizenumber of instances of type value_type for which the space will be allocated.
Returns
a pointer to the allocated storage.
Exceptions
std::bad_allocif size is larger than max_size().
unspecifiedany exception thrown by piranha::aligned_palloc().

Definition at line 139 of file dynamic_aligning_allocator.hpp.

◆ deallocate()

template<typename T>
void piranha::dynamic_aligning_allocator< T >::deallocate ( value_type ptr,
const size_type  
) const
inline

Deallocation function.

The allocation function is a thin wrapper around piranha::aligned_pfree().

Parameters
ptra pointer to a memory block allocated via allocate().
Exceptions
unspecifiedany exception thrown by piranha::aligned_pfree().

Definition at line 155 of file dynamic_aligning_allocator.hpp.

◆ max_size()

template<typename T>
constexpr size_type piranha::dynamic_aligning_allocator< T >::max_size ( ) const
inline

Maximum allocatable size.

Returns
the maximum number of objects of type value_type that can be allocated by a single call to allocate().

Definition at line 124 of file dynamic_aligning_allocator.hpp.

◆ operator!=()

template<typename T>
bool piranha::dynamic_aligning_allocator< T >::operator!= ( const dynamic_aligning_allocator< T > &  other) const
inline

Inequality operator.

Parameters
othercomparison argument.
Returns
the opposite of operator==().

Definition at line 175 of file dynamic_aligning_allocator.hpp.

◆ operator=() [1/2]

template<typename T>
dynamic_aligning_allocator& piranha::dynamic_aligning_allocator< T >::operator= ( const dynamic_aligning_allocator< T > &  other)
default

Copy assignment operator.

Parameters
otherthe assignment argument.
Returns
a reference to this.

◆ operator=() [2/2]

template<typename T>
dynamic_aligning_allocator& piranha::dynamic_aligning_allocator< T >::operator= ( dynamic_aligning_allocator< T > &&  other)
default

Move assignment operator.

Parameters
otherthe assignment argument.
Returns
a reference to this.

◆ operator==()

template<typename T>
bool piranha::dynamic_aligning_allocator< T >::operator== ( const dynamic_aligning_allocator< T > &  other) const
inline

Equality operator.

Parameters
othercomparison argument.
Returns
true if the alignments of this and other coincide, false otherwise.

Definition at line 165 of file dynamic_aligning_allocator.hpp.


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