std::allocator_traits (3) - Linux Manuals

std::allocator_traits: std::allocator_traits

NAME

std::allocator_traits - std::allocator_traits

Synopsis


Defined in header <memory>
template< class Alloc > (since C++11)
struct allocator_traits;


The allocator_traits class template provides the standardized way to access various properties of Allocators. The standard containers and other standard library components access allocators through this template, which makes it possible to use any class type as an allocator, as long as the user-provided specialization of allocator_traits implements all required functionality.
The default, non-specialized, allocator_traits contains the following members:

Member types


Type Definition
allocator_type Alloc
value_type Alloc::value_type
pointer Alloc::pointer if present, otherwise value_type*
const_pointer Alloc::const_pointer if present, otherwise std::pointer_traits<pointer>::rebind<const value_type>
void_pointer Alloc::void_pointer if present, otherwise std::pointer_traits<pointer>::rebind<void>
const_void_pointer Alloc::const_void_pointer if present, otherwise std::pointer_traits<pointer>::rebind<const void>
difference_type Alloc::difference_type if present, otherwise std::pointer_traits<pointer>::difference_type
size_type Alloc::size_type if present, otherwise std::make_unsigned<difference_type>::type
propagate_on_container_copy_assignment Alloc::propagate_on_container_copy_assignment if present, otherwise std::false_type
propagate_on_container_move_assignment Alloc::propagate_on_container_move_assignment if present, otherwise std::false_type
propagate_on_container_swap Alloc::propagate_on_container_swap if present, otherwise std::false_type
is_always_equal(since C++17) Alloc::is_always_equal if present, otherwise std::is_empty<Alloc>::type

Member alias templates


Type Definition
rebind_alloc<T> Alloc::rebind<T>::other if present, otherwise Alloc<T, Args> if this Alloc is Alloc<U, Args>
rebind_traits<T> std::allocator_traits<rebind_alloc<T>>

Member functions


allocate allocates uninitialized storage using the allocator
                                      (public static member function)
[static]


deallocate deallocates storage using the allocator
                                      (public static member function)
[static]


construct constructs an object in the allocated storage
                                      (function template)
[static]


destroy destructs an object stored in the allocated storage
                                      (function template)
[static]


max_size returns the maximum object size supported by the allocator
                                      (public static member function)
[static]


select_on_container_copy_construction obtains the allocator to use after copying a standard container
                                      (public static member function)
[static]

See also


                         the default allocator
allocator (class template)


scoped_allocator_adaptor implements multi-level allocator for multi-level containers
                         (class template)
(C++11)


pointer_traits provides information about pointer-like types
                         (class template)
(C++11)