The class template
scoped_allocator_adaptor is an allocator template that
specifies an allocator resource (the outer allocator) to be used by a container (as any
other allocator does) and also specifies an inner allocator resource to be passed to the
constructor of every element within the container
. This adaptor is instantiated with one
outer and zero or more inner allocator types
. If instantiated with only one allocator
type, the inner allocator becomes the
scoped_allocator_adaptor itself, thus
using the same allocator resource for the container and every element within the
container and, if the elements themselves are containers, each of their elements
recursively
. If instantiated with more than one allocator, the first allocator is the
outer allocator for use by the container, the second allocator is passed to the
constructors of the container's elements, and, if the elements themselves are
containers, the third allocator is passed to the elements' elements, and so on
. If
containers are nested to a depth greater than the number of allocators, the last
allocator is used repeatedly, as in the single-allocator case, for any remaining
recursions
. [
Note 1:
The
scoped_allocator_adaptor is derived from the outer
allocator type so it can be substituted for the outer allocator type in most
expressions
. —
end note]