Share via


scoped_allocator_adaptor Class

Represents a nest of allocators.

template<class Outer, class... Inner>
    class scoped_allocator_adaptor;

Remarks

The template class encapsulates a nest of one or more allocators. Each such class has an outermost allocator of type outer_allocator_type, a synonym for Outer, which is a public base of the scoped_allocator_adaptor object. Outer is used to allocate memory to be used by a container. You can obtain a reference to this allocator base object by calling outer_allocator.

The remainder of the nest has type inner_allocator_type. An inner allocator is used to allocate memory for elements within a container. You can obtain a reference to the stored object of this type by calling inner_allocator. If Inner... is not empty, inner_allocator_type has type scoped_allocator_adaptor<Inner...>, and inner_allocator designates a member object. Otherwise, inner_allocator_type has type scoped_allocator_adaptor<Outer>, and inner_allocator designates the entire object.

The nest behaves as if it has arbitrary depth, replicating its innermost encapsulated allocator as needed.

Several concepts that are not a part of the visible interface aid in describing the behavior of this template class. An outermost allocator mediates all calls to the construct and destroy methods. It is effectively defined by the recursive function OUTERMOST(X), where OUTERMOST(X) is one of the following.

  • If X.outer_allocator() is well formed, then OUTERMOST(X) is OUTERMOST(X.outer_allocator()).

  • Otherwise, OUTERMOST(X) is X.

Three types are defined for the sake of exposition:

Type

Description

Outermost

The type of OUTERMOST(*this).

Outermost_traits

allocator_traits<Outermost>

Outer_traits

allocator_traits<Outer>

Constructors

Name

Description

scoped_allocator_adaptor::scoped_allocator_adaptor Constructor

Constructs a scoped_allocator_adaptor object.

Typedefs

Name

Description

const_pointer

This type is a synonym for the const_pointer that is associated with the allocator Outer.

const_void_pointer

This type is a synonym for the const_void_pointer that is associated with the allocator Outer.

difference_type

This type is a synonym for the difference_type that is associated with the allocator Outer.

inner_allocator_type

This type is a synonym for the type of the nested adaptor scoped_allocator_adaptor<Inner...>.

outer_allocator_type

This type is a synonym for the type of the base allocator Outer.

pointer

This type is a synonym for the pointer associated with the allocator Outer.

propagate_on_container_copy_assignment

The type holds true only if Outer_traits::propagate_on_container_copy_assignment holds true or inner_allocator_type::propagate_on_container_copy_assignment holds true.

propagate_on_container_move_assignment

The type holds true only if Outer_traits::propagate_on_container_move_assignment holds true or inner_allocator_type::propagate_on_container_move_assignment holds true.

propagate_on_container_swap

The type holds true only if Outer_traits::propagate_on_container_swap holds true or inner_allocator_type::propagate_on_container_swap holds true.

size_type

This type is a synonym for the size_type associated with the allocator Outer.

value_type

This type is a synonym for the value_type associated with the allocator Outer.

void_pointer

This type is a synonym for the void_pointer associated with the allocator Outer.

Structs

Name

Description

scoped_allocator_adaptor::rebind Struct

Defines the type Outer::rebind<Other>::other as a synonym for scoped_allocator_adaptor<Other, Inner...>.

Methods

Name

Description

scoped_allocator_adaptor::allocate Method

Allocates memory by using the Outer allocator.

scoped_allocator_adaptor::construct Method

Constructs an object.

scoped_allocator_adaptor::deallocate Method

Deallocates objects by using the outer allocator.

scoped_allocator_adaptor::destroy Method

Destroys a specified object.

scoped_allocator_adaptor::inner_allocator Method

Retrieves a reference to the stored object of type inner_allocator_type.

scoped_allocator_adaptor::max_size Method

Determines the maximum number of objects that can be allocated by the outer allocator.

scoped_allocator_adaptor::outer_allocator Method

Retrieves a reference to the stored object of type outer_allocator_type.

scoped_allocator_adaptor::select_on_container_copy_construction Method

Creates a new scoped_allocator_adaptor object with each stored allocator object initialized by calling select_on_container_copy_construction for each corresponding allocator.

Requirements

Header: <scoped_allocator>

Namespace: std

See Also

Other Resources

Header Files