WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
wpi::memory::aligned_allocator< RawAllocator > Class Template Reference

A RawAllocator adapter that ensures a minimum alignment. More...

#include <wpi/memory/aligned_allocator.hpp>

Public Types

using allocator_type = typename allocator_traits<RawAllocator>::allocator_type
 
using is_stateful = std::true_type
 

Public 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
 
void * try_allocate_node (std::size_t size, std::size_t alignment) noexcept
 
void * try_allocate_array (std::size_t count, std::size_t size, std::size_t alignment) noexcept
 
bool try_deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept
 
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_typeget_allocator () noexcept
 
const allocator_typeget_allocator () const noexcept
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

template<class RawAllocator>
class wpi::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.

Member Typedef Documentation

◆ allocator_type

template<class RawAllocator >
using wpi::memory::aligned_allocator< RawAllocator >::allocator_type = typename allocator_traits<RawAllocator>::allocator_type

◆ is_stateful

template<class RawAllocator >
using wpi::memory::aligned_allocator< RawAllocator >::is_stateful = std::true_type

Constructor & Destructor Documentation

◆ aligned_allocator() [1/2]

template<class RawAllocator >
wpi::memory::aligned_allocator< RawAllocator >::aligned_allocator ( std::size_t min_alignment,
allocator_type && alloc = {} )
inlineexplicit
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 >
wpi::memory::aligned_allocator< RawAllocator >::aligned_allocator ( aligned_allocator< RawAllocator > && other)
inlinenoexcept
Effects:
Moves the aligned_allocator object. It simply moves the underlying allocator.

Member Function Documentation

◆ allocate_array()

template<class RawAllocator >
void * wpi::memory::aligned_allocator< RawAllocator >::allocate_array ( std::size_t count,
std::size_t size,
std::size_t alignment )
inline

◆ allocate_node()

template<class RawAllocator >
void * wpi::memory::aligned_allocator< RawAllocator >::allocate_node ( std::size_t size,
std::size_t alignment )
inline
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 wpi::memory::aligned_allocator< RawAllocator >::deallocate_array ( void * ptr,
std::size_t count,
std::size_t size,
std::size_t alignment )
inlinenoexcept

◆ deallocate_node()

template<class RawAllocator >
void wpi::memory::aligned_allocator< RawAllocator >::deallocate_node ( void * ptr,
std::size_t size,
std::size_t alignment )
inlinenoexcept

◆ get_allocator() [1/2]

template<class RawAllocator >
const allocator_type & wpi::memory::aligned_allocator< RawAllocator >::get_allocator ( ) const
inlinenoexcept

◆ get_allocator() [2/2]

template<class RawAllocator >
allocator_type & wpi::memory::aligned_allocator< RawAllocator >::get_allocator ( )
inlinenoexcept
Returns:
A reference to the underlying allocator.

◆ max_alignment()

template<class RawAllocator >
std::size_t wpi::memory::aligned_allocator< RawAllocator >::max_alignment ( ) const
inline

◆ max_array_size()

template<class RawAllocator >
std::size_t wpi::memory::aligned_allocator< RawAllocator >::max_array_size ( ) const
inline

◆ max_node_size()

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

◆ min_alignment()

template<class RawAllocator >
std::size_t wpi::memory::aligned_allocator< RawAllocator >::min_alignment ( ) const
inlinenoexcept
Returns:
The minimum alignment.

◆ operator=()

template<class RawAllocator >
aligned_allocator & wpi::memory::aligned_allocator< RawAllocator >::operator= ( aligned_allocator< RawAllocator > && other)
inlinenoexcept

◆ set_min_alignment()

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

◆ try_allocate_array()

template<class RawAllocator >
void * wpi::memory::aligned_allocator< RawAllocator >::try_allocate_array ( std::size_t count,
std::size_t size,
std::size_t alignment )
inlinenoexcept

◆ try_allocate_node()

template<class RawAllocator >
void * wpi::memory::aligned_allocator< RawAllocator >::try_allocate_node ( std::size_t size,
std::size_t alignment )
inlinenoexcept
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 >
bool wpi::memory::aligned_allocator< RawAllocator >::try_deallocate_array ( void * ptr,
std::size_t count,
std::size_t size,
std::size_t alignment )
inlinenoexcept

◆ try_deallocate_node()

template<class RawAllocator >
bool wpi::memory::aligned_allocator< RawAllocator >::try_deallocate_node ( void * ptr,
std::size_t size,
std::size_t alignment )
inlinenoexcept

Friends And Related Symbol Documentation

◆ 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.

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