Share via


allocator_traits Class

The template class describes an object that supplements an allocator type. An allocator type is any type that describes an allocator object that is used for managing allocated storage. Specifically, for any allocator type Alloc, you can use allocator_traits<Alloc> to determine all the information that is needed by an allocator-enabled container. For more information, see the default allocator Class.

template<class Alloc>
    class allocator_traits;

Typedefs

Name

Description

allocator_traits::allocator_type

This type is a synonym for the template parameter Alloc.

allocator_traits::const_pointer

This type is Alloc::const_pointer, if that type is well-formed; otherwise, this type is pointer_traits<pointer>::rebind<const value_type>.

allocator_traits::const_void_pointer

This type is Alloc::const_void_pointer, if that type is well-formed; otherwise, this type is pointer_traits<pointer>::rebind<const void>.

allocator_traits::difference_type

This type is Alloc::difference_type, if that type is well-formed; otherwise, this type is pointer_traits<pointer>::difference_type.

allocator_traits::pointer

This type is Alloc::pointer, if that type is well-formed; otherwise, this type is value_type *.

allocator_traits::propagate_on_container_copy_assignment

This type is Alloc::propagate_on_container_copy_assignment, if that type is well-formed; otherwise, this type is false_type.

allocator_traits::propagate_on_container_move_assignment

This type is Alloc::propagate_on_container_move_assignment, if that type is well-formed; otherwise, this type is false_type. If the type holds true, an allocator-enabled container copies its stored allocator on a move assignment.

allocator_traits::propagate_on_container_swap

This type is Alloc::propagate_on_container_swap, if that type is well-formed; otherwise, this type is false_type. If the type holds true, an allocator-enabled container swaps its stored allocator on a swap.

allocator_traits::size_type

This type is Alloc::size_type, if that type is well-formed; otherwise, this type is make_unsigned<difference_type>::type.

allocator_traits::value_type

This type is a synonym for Alloc::value_type.

allocator_traits::void_pointer

This type is Alloc::void_pointer, if that type is well-formed; otherwise, this type is pointer_traits<pointer>::rebind<void>.

Static Methods

The following static methods call the corresponding method on a given allocator parameter.

Name

Description

allocator_traits::allocate Method

Static method that allocates memory by using the given allocator parameter.

allocator_traits::construct Method

Static method that uses a specified allocator to construct an object.

allocator_traits::deallocate Method

Static method that uses a specified allocator to deallocate a specified number of objects.

allocator_traits::destroy Method

Static method that uses a specified allocator to call the destructor on an object without deallocating its memory.

allocator_traits::max_size Method

Static method that uses a specified allocator to determine the maximum number of objects that can be allocated.

allocator_traits::select_on_container_copy_construction Method

Static method that calls select_on_container_copy_construction on the specified allocator.

Requirements

Header: <memory>

Namespace: std

See Also

Reference

<memory>

pointer_traits Struct

scoped_allocator_adaptor Class