µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::estd::pmr::polymorphic_allocator< T > Class Template Reference

#include <memory_resource>

Public Types

typedef T value_type
 

Public Member Functions

 polymorphic_allocator () noexcept
 
 polymorphic_allocator (memory_resource *r) noexcept
 
 polymorphic_allocator (polymorphic_allocator const &a)=default
 
template<typename U >
 polymorphic_allocator (polymorphic_allocator< U > const &other) noexcept
 
value_typeallocate (std::size_t n)
 
void deallocate (value_type *p, std::size_t n) noexcept
 
std::size_t max_size (void) const noexcept
 
polymorphic_allocatoroperator= (polymorphic_allocator const &a)=default
 
memory_resourceresource (void) const noexcept
 
polymorphic_allocator select_on_container_copy_construction (void) const noexcept
 

Private Attributes

memory_resourceres_
 

Detailed Description

template<typename T>
class os::estd::pmr::polymorphic_allocator< T >

Definition at line 120 of file memory_resource.

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T os::estd::pmr::polymorphic_allocator< T >::value_type

Definition at line 123 of file memory_resource.

Constructor & Destructor Documentation

◆ polymorphic_allocator() [1/4]

template<typename T >
os::estd::pmr::polymorphic_allocator< T >::polymorphic_allocator
noexcept

Definition at line 190 of file memory_resource.

192 {
193 }
memory_resource * get_default_resource(void) noexcept
Get the default application memory manager.

◆ polymorphic_allocator() [2/4]

template<typename T >
os::estd::pmr::polymorphic_allocator< T >::polymorphic_allocator ( memory_resource r)
inlinenoexcept

Definition at line 196 of file memory_resource.

198 : res_ (r)
199 {
200 }

◆ polymorphic_allocator() [3/4]

template<typename T >
os::estd::pmr::polymorphic_allocator< T >::polymorphic_allocator ( polymorphic_allocator< T > const &  a)
default

◆ polymorphic_allocator() [4/4]

template<typename T >
template<typename U >
os::estd::pmr::polymorphic_allocator< T >::polymorphic_allocator ( polymorphic_allocator< U > const &  other)
inlinenoexcept

Definition at line 204 of file memory_resource.

206 : res_ (other.resource ())
207 {
208 }

Member Function Documentation

◆ allocate()

template<typename T >
polymorphic_allocator< T >::value_type * os::estd::pmr::polymorphic_allocator< T >::allocate ( std::size_t  n)
inline

Definition at line 212 of file memory_resource.

213 {
214 if (n > max_size ())
215 {
217 EINVAL, "polymorphic_allocator<T>::allocate(std::size_t n)"
218 " 'n' exceeds maximum supported size");
219 }
220
221 return static_cast<value_type*> (
222 res_->allocate (n * sizeof (value_type), alignof (value_type)));
223 }
std::size_t max_size(void) const noexcept
void * allocate(std::size_t bytes, std::size_t alignment=max_align)
Allocate a memory block.
Definition os-memory.h:1290
void __throw_system_error(int ev, const char *what_arg)

References os::rtos::memory::memory_resource::allocate().

◆ deallocate()

template<typename T >
void os::estd::pmr::polymorphic_allocator< T >::deallocate ( value_type p,
std::size_t  n 
)
inlinenoexcept

Definition at line 227 of file memory_resource.

229 {
230 assert (n <= max_size ());
231 res_->deallocate (p, n * sizeof (value_type), alignof (value_type));
232 }
void deallocate(void *addr, std::size_t bytes, std::size_t alignment=max_align) noexcept
Deallocate the previously allocated memory block.
Definition os-memory.h:1312

References os::rtos::memory::memory_resource::deallocate().

◆ max_size()

template<typename T >
std::size_t os::estd::pmr::polymorphic_allocator< T >::max_size ( void  ) const
inlinenoexcept

Definition at line 236 of file memory_resource.

237 {
238 return std::numeric_limits<std::size_t>::max () / sizeof (value_type);
239 }

◆ operator=()

template<typename T >
polymorphic_allocator & os::estd::pmr::polymorphic_allocator< T >::operator= ( polymorphic_allocator< T > const &  a)
default

◆ resource()

template<typename T >
memory_resource * os::estd::pmr::polymorphic_allocator< T >::resource ( void  ) const
inlinenoexcept

Definition at line 251 of file memory_resource.

252 {
253 return res_;
254 }

◆ select_on_container_copy_construction()

template<typename T >
polymorphic_allocator< T > os::estd::pmr::polymorphic_allocator< T >::select_on_container_copy_construction ( void  ) const
inlinenoexcept

Definition at line 243 of file memory_resource.

245 {
246 return polymorphic_allocator ();
247 }

Member Data Documentation

◆ res_

template<typename T >
memory_resource* os::estd::pmr::polymorphic_allocator< T >::res_
private

Definition at line 154 of file memory_resource.


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