From cppreference.com
template<classAlloc>structallocator_traits;(since C++11)The allocator_traits class template provides the standardized way to access various properties of
. 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 std::allocator_traits implements all required functionality.
A program that declares an explicit or partial specialization of std::allocator_traits is ill-formed, no diagnostic required.
(since C++23)The default, non-specialized, std::allocator_traits contains the following members:
Member types
Type Definition allocator_typeAllocvalue_typeAlloc::value_typepointerAlloc::pointer if present, otherwise value_type*const_pointerAlloc::const_pointer if present, otherwise std::pointer_traits<pointer>::rebind<constvalue_type>void_pointerAlloc::void_pointer if present, otherwise std::pointer_traits<pointer>::rebind<void>const_void_pointerAlloc::const_void_pointer if present, otherwise std::pointer_traits<pointer>::rebind<constvoid>difference_typeAlloc::difference_type if present, otherwise std::pointer_traits<pointer>::difference_typesize_typeAlloc::size_type if present, otherwise std::make_unsigned<difference_type>::typepropagate_on_container_copy_assignmentAlloc::propagate_on_container_copy_assignment if present, otherwise
propagate_on_container_move_assignmentAlloc::propagate_on_container_move_assignment if present, otherwise
propagate_on_container_swapAlloc::propagate_on_container_swap if present, otherwise
is_always_equalAlloc::is_always_equal if present, otherwise std::is_empty<Alloc>::typeMember alias templates
Type Definition rebind_alloc<T>Alloc::rebind<T>::other if present, otherwise SomeAllocator<T, Args> if this Alloc is of the form SomeAllocator<U,Args>, where Args is zero or more
rebind_traits<T>std::allocator_traits<rebind_alloc<T>>Member functions
[static]
allocates uninitialized storage using the allocator
(public static member function)
[static](C++23)
allocates storage at least as large as the requested size via an allocator
(public static member function)
[static]
deallocates storage using the allocator
(public static member function)
[static]
constructs an object in the allocated storage
(function template)
[static]
destructs an object stored in the allocated storage
(function template)
[static]
returns the maximum object size supported by the allocator
(public static member function)
select_on_container_copy_construction
[static]
obtains the allocator to use after copying a standard container
(public static member function)
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
C++11 there was no way to show an allocator is stateless is_always_equal provided See also