memory
aligned_allocator< RawAllocator > Class Template Reference

Detailed Description

template<class RawAllocator>
class foonathan::memory::aligned_allocator< RawAllocator >

A RawAllocator adapter that ensures a minimum alignment.

It adjusts the alignment value so that it is always larger than the minimum and forwards to the specified allocator.

Typedefs

using allocator_type
 
using is_stateful
 

Member Functions

 aligned_allocator (std::size_t min_alignment, allocator_type &&alloc={})
 
std::size_t min_alignment () const noexcept
 
void set_min_alignment (std::size_t min_alignment)
 
 aligned_allocator (aligned_allocator &&other) noexcept
 
aligned_allocatoroperator= (aligned_allocator &&other) noexcept
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void * allocate_array (std::size_t count, std::size_t size, std::size_t alignment)
 
void deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept
 
void deallocate_array (void *ptr, std::size_t count, std::size_t size, std::size_t alignment) noexcept
 
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
void * try_allocate_node (std::size_t size, std::size_t alignment) noexcept
 
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
void * try_allocate_array (std::size_t count, std::size_t size, std::size_t alignment) noexcept
 
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
bool try_deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept
 
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
bool try_deallocate_array (void *ptr, std::size_t count, std::size_t size, std::size_t alignment) noexcept
 
std::size_t max_node_size () const
 
std::size_t max_array_size () const
 
std::size_t max_alignment () const
 
allocator_type & get_allocator () noexcept
 
const allocator_type & get_allocator () const noexcept
 

Related Symbols

template<class RawAllocator>
auto make_aligned_allocator (std::size_t min_alignment, RawAllocator &&allocator) noexcept -> aligned_allocator< typename std::decay< RawAllocator >::type >
 

Constructors

◆ aligned_allocator() [1/2]

template<class RawAllocator>
aligned_allocator ( std::size_t min_alignment,
allocator_type && alloc = {} )
explicit
Effects:
Creates it passing it the minimum alignment value and the allocator object.
Requires:
min_alignment must be less than this->max_alignment().

◆ aligned_allocator() [2/2]

template<class RawAllocator>
aligned_allocator ( aligned_allocator< RawAllocator > && other)
noexcept
Effects:
Moves the aligned_allocator object. It simply moves the underlying allocator.

Member Functions

◆ operator=()

template<class RawAllocator>
aligned_allocator & operator= ( aligned_allocator< RawAllocator > && other)
noexcept
Effects:
Moves the aligned_allocator object. It simply moves the underlying allocator.

◆ allocate_node()

template<class RawAllocator>
void * allocate_node ( std::size_t size,
std::size_t alignment )
Effects:
Forwards to the underlying allocator through the allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.

◆ allocate_array()

template<class RawAllocator>
void * allocate_array ( std::size_t count,
std::size_t size,
std::size_t alignment )
Effects:
Forwards to the underlying allocator through the allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.

◆ deallocate_node()

template<class RawAllocator>
void deallocate_node ( void * ptr,
std::size_t size,
std::size_t alignment )
noexcept
Effects:
Forwards to the underlying allocator through the allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.

◆ deallocate_array()

template<class RawAllocator>
void deallocate_array ( void * ptr,
std::size_t count,
std::size_t size,
std::size_t alignment )
noexcept
Effects:
Forwards to the underlying allocator through the allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.

◆ try_allocate_node()

template<class RawAllocator>
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
void * try_allocate_node ( std::size_t size,
std::size_t alignment )
noexcept
Effects:
Forwards to the underlying allocator through the composable_allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.
Requires:
The underyling allocator must be composable.

◆ try_allocate_array()

template<class RawAllocator>
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
void * try_allocate_array ( std::size_t count,
std::size_t size,
std::size_t alignment )
noexcept
Effects:
Forwards to the underlying allocator through the composable_allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.
Requires:
The underyling allocator must be composable.

◆ try_deallocate_node()

template<class RawAllocator>
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
bool try_deallocate_node ( void * ptr,
std::size_t size,
std::size_t alignment )
noexcept
Effects:
Forwards to the underlying allocator through the composable_allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.
Requires:
The underyling allocator must be composable.

◆ try_deallocate_array()

template<class RawAllocator>
template<typename Dummy = std::true_type, typename std::enable_if<(Dummy::value &&(composable::value)), int >::type = 0>
bool try_deallocate_array ( void * ptr,
std::size_t count,
std::size_t size,
std::size_t alignment )
noexcept
Effects:
Forwards to the underlying allocator through the composable_allocator_traits. If the alignment is less than the min_alignment(), it is set to the minimum alignment.
Requires:
The underyling allocator must be composable.

◆ max_node_size()

template<class RawAllocator>
std::size_t max_node_size ( ) const
Returns:
The value returned by the allocator_traits for the underlying allocator.

◆ max_array_size()

template<class RawAllocator>
std::size_t max_array_size ( ) const
Returns:
The value returned by the allocator_traits for the underlying allocator.

◆ max_alignment()

template<class RawAllocator>
std::size_t max_alignment ( ) const
Returns:
The value returned by the allocator_traits for the underlying allocator.

◆ get_allocator() [1/2]

template<class RawAllocator>
allocator_type & get_allocator ( )
noexcept
Returns:
A reference to the underlying allocator.

◆ get_allocator() [2/2]

template<class RawAllocator>
const allocator_type & get_allocator ( ) const
noexcept
Returns:
A reference to the underlying allocator.

◆ min_alignment()

template<class RawAllocator>
std::size_t min_alignment ( ) const
noexcept
Returns:
The minimum alignment.

◆ set_min_alignment()

template<class RawAllocator>
void set_min_alignment ( std::size_t min_alignment)
Effects:
Sets the minimum alignment to a new value.
Requires:
min_alignment must be less than this->max_alignment().

Related Functions

◆ make_aligned_allocator()

template<class RawAllocator>
auto make_aligned_allocator ( std::size_t min_alignment,
RawAllocator && allocator ) -> aligned_allocator<typename std::decay<RawAllocator>::type>
related
Returns:
A new aligned_allocator created by forwarding the parameters to the constructor.