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

Wraps a RawAllocator and makes it a "normal" Allocator. More...

#include <wpi/memory/std_allocator.hpp>

Classes

struct  rebind
 

Public Types

using value_type = T
 
using pointer = T*
 
using const_pointer = const T*
 
using reference = T&
 
using const_reference = const T&
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using propagate_on_container_swap = typename prop_traits::propagate_on_container_swap
 
using propagate_on_container_move_assignment
 
using propagate_on_container_copy_assignment
 
using allocator_type = typename alloc_reference::allocator_type
 

Public Member Functions

 std_allocator () noexcept
 
template<class RawAlloc >
 std_allocator (RawAlloc &alloc,) noexcept
 
template<class RawAlloc >
 std_allocator (const RawAlloc &alloc,) noexcept
 
 std_allocator (const alloc_reference &alloc) noexcept
 
template<class StoragePolicy , class OtherMut >
 std_allocator (const allocator_storage< StoragePolicy, OtherMut > &)=delete
 
std_allocator< T, RawAllocator > select_on_container_copy_construction () const
 
pointer allocate (size_type n, void *=nullptr)
 
void deallocate (pointer p, size_type n) noexcept
 
template<typename U , typename... Args>
void construct (U *p, Args &&... args)
 
template<typename U >
void destroy (U *p) noexcept
 
size_type max_size () const noexcept
 
template<typename U >
 std_allocator (const std_allocator< U, RawAllocator > &alloc) noexcept
 
template<typename U >
 std_allocator (std_allocator< U, RawAllocator > &alloc) noexcept
 
auto get_allocator () noexcept -> decltype(std::declval< alloc_reference >().get_allocator())
 
auto get_allocator () const noexcept -> decltype(std::declval< const alloc_reference >().get_allocator())
 

Friends

template<typename U , class OtherRawAllocator >
class std_allocator
 
template<typename T1 , typename T2 , class Impl >
bool operator== (const std_allocator< T1, Impl > &lhs, const std_allocator< T2, Impl > &rhs) noexcept
 

Related Symbols

(Note that these are not member symbols.)

template<typename T , typename U , class Impl >
bool operator== (const std_allocator< T, Impl > &lhs, const std_allocator< U, Impl > &rhs) noexcept
 
template<typename T , typename U , class Impl >
bool operator!= (const std_allocator< T, Impl > &lhs, const std_allocator< U, Impl > &rhs) noexcept
 
template<typename T , class RawAllocator >
auto make_std_allocator (RawAllocator &&allocator) noexcept -> std_allocator< T, typename std::decay< RawAllocator >::type >
 

Detailed Description

template<typename T, class RawAllocator>
class wpi::memory::std_allocator< T, RawAllocator >

Wraps a RawAllocator and makes it a "normal" Allocator.

It allows using a RawAllocator anywhere a Allocator is required.

Member Typedef Documentation

◆ allocator_type

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::allocator_type = typename alloc_reference::allocator_type

◆ const_pointer

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::const_pointer = const T*

◆ const_reference

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::const_reference = const T&

◆ difference_type

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::difference_type = std::ptrdiff_t

◆ pointer

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::pointer = T*

◆ propagate_on_container_copy_assignment

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::propagate_on_container_copy_assignment
Initial value:
decltype(traits_detail::propagate_on_container_copy_assignment< RawAllocator >( traits_detail::full_concept{})) propagate_on_container_copy_assignment
Definition std_allocator.hpp:59

◆ propagate_on_container_move_assignment

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::propagate_on_container_move_assignment
Initial value:
decltype(traits_detail::propagate_on_container_move_assignment< RawAllocator >( traits_detail::full_concept{})) propagate_on_container_move_assignment
Definition std_allocator.hpp:55

◆ propagate_on_container_swap

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::propagate_on_container_swap = typename prop_traits::propagate_on_container_swap

◆ reference

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::reference = T&

◆ size_type

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::size_type = std::size_t

◆ value_type

template<typename T , class RawAllocator >
using wpi::memory::std_allocator< T, RawAllocator >::value_type = T

Constructor & Destructor Documentation

◆ std_allocator() [1/7]

template<typename T , class RawAllocator >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( )
inlinenoexcept
Effects:
Default constructs it by storing a default constructed, stateless RawAllocator inside the reference.
Requires:
The RawAllocator type is stateless, otherwise the body of this function will not compile.

◆ std_allocator() [2/7]

template<typename T , class RawAllocator >
template<class RawAlloc >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( RawAlloc & alloc)
inlinenoexcept
Effects:
Creates it from a reference to a RawAllocator. It will store an allocator_reference to it.
Requires:
The expression allocator_reference<RawAllocator>(alloc) is well-formed, that is either RawAlloc is the same as RawAllocator or RawAllocator is the tag type any_allocator. If the requirement is not fulfilled this function does not participate in overload resolution.
Note
The caller has to ensure that the lifetime of the RawAllocator is at least as long as the lifetime of this std_allocator object.

◆ std_allocator() [3/7]

template<typename T , class RawAllocator >
template<class RawAlloc >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( const RawAlloc & alloc)
inlinenoexcept
Effects:
Creates it from a stateless, temporary RawAllocator object. It will not store a reference but create it on the fly.
Requires:
The RawAllocator is stateless and the expression allocator_reference<RawAllocator>(alloc) is well-formed as above, otherwise this function does not participate in overload resolution.

◆ std_allocator() [4/7]

template<typename T , class RawAllocator >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( const alloc_reference & alloc)
inlinenoexcept
Effects:
Creates it from another allocator_reference using the same allocator type.

◆ std_allocator() [5/7]

template<typename T , class RawAllocator >
template<class StoragePolicy , class OtherMut >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( const allocator_storage< StoragePolicy, OtherMut > & )
delete

Implicit conversion from any other allocator_storage is forbidden to prevent accidentally wrapping another allocator_storage inside a allocator_reference.

◆ std_allocator() [6/7]

template<typename T , class RawAllocator >
template<typename U >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( const std_allocator< U, RawAllocator > & alloc)
inlinenoexcept
Effects:
Creates it from another std_allocator allocating a different type. This is required by the Allcoator concept and simply takes the same allocator_reference.

◆ std_allocator() [7/7]

template<typename T , class RawAllocator >
template<typename U >
wpi::memory::std_allocator< T, RawAllocator >::std_allocator ( std_allocator< U, RawAllocator > & alloc)
inlinenoexcept

Member Function Documentation

◆ allocate()

template<typename T , class RawAllocator >
pointer wpi::memory::std_allocator< T, RawAllocator >::allocate ( size_type n,
void * = nullptr )
inline
Effects:
Allocates memory using the underlying RawAllocator. If n is 1, it will call allocate_node(sizeof(T), alignof(T)), otherwise allocate_array(n, sizeof(T), alignof(T)).
Returns:
A pointer to a memory block suitable for n objects of type T.
Throws:
Anything thrown by the RawAllocator.

◆ construct()

template<typename T , class RawAllocator >
template<typename U , typename... Args>
void wpi::memory::std_allocator< T, RawAllocator >::construct ( U * p,
Args &&... args )
inline
Effects:
Creates an object of type U at given address using the passed arguments.

◆ deallocate()

template<typename T , class RawAllocator >
void wpi::memory::std_allocator< T, RawAllocator >::deallocate ( pointer p,
size_type n )
inlinenoexcept
Effects:
Deallcoates memory using the underlying RawAllocator. It will forward to the deallocation function in the same way as in allocate().
Requires:
The pointer must come from a previous call to allocate() with the same n on this object or any copy of it.

◆ destroy()

template<typename T , class RawAllocator >
template<typename U >
void wpi::memory::std_allocator< T, RawAllocator >::destroy ( U * p)
inlinenoexcept
Effects:
Calls the destructor for an object of type U at given address.

◆ get_allocator() [1/2]

template<typename T , class RawAllocator >
auto wpi::memory::std_allocator< T, RawAllocator >::get_allocator ( ) const -> decltype(std::declval<const alloc_reference>().get_allocator())
inlinenoexcept

◆ get_allocator() [2/2]

template<typename T , class RawAllocator >
auto wpi::memory::std_allocator< T, RawAllocator >::get_allocator ( ) -> decltype(std::declval<alloc_reference>().get_allocator())
inlinenoexcept
Effects:
Returns a reference to the referenced allocator.
Returns:
For stateful allocators: A (const) reference to the stored allocator. For stateless allocators: A temporary constructed allocator.

◆ max_size()

template<typename T , class RawAllocator >
size_type wpi::memory::std_allocator< T, RawAllocator >::max_size ( ) const
inlinenoexcept
Returns:
The maximum size for an allocation which is max_array_size() / sizeof(value_type). This is only an upper bound, not the exact maximum.

◆ select_on_container_copy_construction()

template<typename T , class RawAllocator >
std_allocator< T, RawAllocator > wpi::memory::std_allocator< T, RawAllocator >::select_on_container_copy_construction ( ) const
inline
Returns:
A copy of the allocator. This is required by the Allocator concept and forwards to the propagation_traits.

Friends And Related Symbol Documentation

◆ make_std_allocator()

template<typename T , class RawAllocator >
auto make_std_allocator ( RawAllocator && allocator) -> std_allocator<T, typename std::decay<RawAllocator>::type>
related
Returns:
A new std_allocator for a given type using a certain allocator object.

◆ operator!=()

template<typename T , typename U , class Impl >
bool operator!= ( const std_allocator< T, Impl > & lhs,
const std_allocator< U, Impl > & rhs )
related
Effects:
Compares two std_allocator object, they are equal if either stateless or reference the same allocator.
Returns:
The result of the comparision for inequality.

◆ operator==() [1/2]

template<typename T , typename U , class Impl >
bool operator== ( const std_allocator< T, Impl > & lhs,
const std_allocator< U, Impl > & rhs )
related
Effects:
Compares two std_allocator object, they are equal if either stateless or reference the same allocator.
Returns:
The result of the comparision for equality.

◆ operator== [2/2]

template<typename T , class RawAllocator >
template<typename T1 , typename T2 , class Impl >
bool operator== ( const std_allocator< T1, Impl > & lhs,
const std_allocator< T2, Impl > & rhs )
friend

◆ std_allocator

template<typename T , class RawAllocator >
template<typename U , class OtherRawAllocator >
friend class std_allocator
friend

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