<scoped_allocator>
[added with C++11]
operator!==
· operator==
· scoped_allocator_adaptor
Include the standard
header <scoped_allocator>
to define the
template class scoped_allocator_adaptor
and two supporting templates.
namespace std { template<class Outer, class... Inner> class scoped_allocator_adaptor; // TEMPLATE FUNCTIONS template<class Outer, class... Inner> bool operator==( const scoped_allocator_adaptor<Outer, Inner...>& left, const scoped_allocator_adaptor<Outer, Inner...>& right) noexcept; template<class Outer, class... Inner> bool operator!=( const scoped_allocator_adaptor<Outer, Inner...>& left, const scoped_allocator_adaptor<Outer, Inner...>& right) noexcept; } // namespace std
operator!=
template<class Ty, size_t N> bool operator!=( const scoped_allocator_adaptor<Outer, Inner...>& left, const scoped_allocator_adaptor<Outer, Inner...>& right) noexcept;
The template function returns !(left == right)
.
operator==
template<class Outer, class... Inner> bool operator==( const scoped_allocator_adaptor<Outer, Inner...>& left, const scoped_allocator_adaptor<Outer, Inner...>& right) noexcept;
The template function returns
left.outer_allocator() == right.outer_allocator()
&& left.inner_allocator() == right.inner_allocator()
.
scoped_allocator_adaptor
allocate
· const_pointer
· const_void_pointer
· construct
· deallocate
· destroy
· difference_type
· inner_allocator
· inner_allocator_type
· max_size
· outer_allocator
· outer_allocator_type
· pointer
· propagate_on_container_copy_assignment
· propagate_on_container_move_assignment
· propagate_on_container_swap
· rebind
· scoped_allocator_adaptor
· select_on_container_copy_construction
· size_type
· value_type
· void_pointer
template<class Outer, class... Inner> class scoped_allocator_adaptor { typedef T0 Outermost; // exposition only typedef allocator_traits<Outer> Outer_traits; // exposition only typedef allocator_traits<Outermost> Outermost_traits; // exposition only public: typedef typename Outer_traits::value_type value_type; typedef typename Outer_traits::pointer pointer; typedef typename Outer_traits::const_pointer const_pointer; typedef typename Outer_traits::void_pointer void_pointer; typedef typename Outer_traits::const_void_pointer const_void_pointer; typedef typename Outer_traits::size_type size_type; typedef typename Outer_traits::difference_type difference_type; template<class Other> struct rebind; typedef T1 propagate_on_container_copy_assignment; typedef T2 propagate_on_container_move_assignment; typedef T3 propagate_on_container_swap; scoped_allocator_adaptor(); scoped_allocator_adaptor(const scoped_allocator_adaptor& right) noexcept; template<class Outer2> scoped_allocator_adaptor( const scoped_allocator_adaptor<Outer2, Inner...>& right) noexcept; template<class Outer2> scoped_allocator_adaptor( scoped_allocator_adaptor<Outer2, Inner...>&& right) noexcept; template<class Outer2> scoped_allocator_adaptor(Outer2&& al, const Inner&... rest) noexcept; inner_allocator_type& inner_allocator() noexcept; const inner_allocator_type& inner_allocator() const noexcept; outer_allocator_type& outer_allocator() noexcept; const outer_allocator_type& outer_allocator() const noexcept; pointer allocate(size_type count); pointer allocate(size_type count, const_void_pointer hint); void deallocate(pointer ptr, size_type count); size_type max_size(); template<class Ty, class... Atypes> void construct(Ty *ptr, Atypes&&... args); template<class Ty1, class Ty2, class... Atypes1, class... Atypes2> void construct(pair<Ty1, Ty2> *ptr, piecewise_construct_t, tuple<Atypes1&&...> first, tuple<Atypes1&&...> second); template<class Ty1, class Ty2> void construct(pair<Ty1, Ty2> *ptr); template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, class Uy1&& first, class Uy2&& second); template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, const pair<Uy1, Uy2>& right); template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, pair<Uy1, Uy2>&& right); template<class Ty> void destroy(Ty *ptr); scoped_allocator_adaptor select_on_container_copy_construction(); };
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.
You can obtain a reference to this allocator base object by calling the member function
outer_allocator()
.
The remainder of the nest has type inner_allocator_type
.
You can obtain a reference to the stored object of this type
by calling the member function 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.
Thus, the nest behaves as if it has arbitrary depth, replicating its innermost encapsulated allocator as needed.
Several concepts, not a part of the visible interface, aid in describing the behavior of this template class:
An outermost allocator mediates all calls to the member functions
construct
and destroy
. It is effectively defined
by the recursive function OUTERMOST(X)
:
X.outer_allocator()
is well formed, then
OUTERMOST(X)
is OUTERMOST(X.outer_allocator())
.OUTERMOST(X)
is X
.Three types are defined for the sake of exposition:
Outermost
-- the type of OUTERMOST(*this)
(It is described above as a
synonym for the implementation-defined type T0
.)Outermost_traits
-- allocator_traits<Outermost>
Outer_traits
-- allocator_traits<Outer>
scoped_allocator_adaptor::allocate
pointer allocate(size_type count); pointer allocate(size_type count, const_void_pointer hint);
The first member function returns
Outer_traits::allocate(outer_allocator(), count)
.
The second member function returns
Outer_traits::allocate(outer_allocator(), count, hint)
.
scoped_allocator_adaptor::const_pointer
typedef typename Outer_traits::const_pointer const_pointer;
The type is a synonym for the const_pointer
associated with the allocator Outer
.
scoped_allocator_adaptor::const_void_pointer
typedef typename Outer_traits::const_void_pointer const_void_pointer;
The type is a synonym for the const_void_pointer
associated with the allocator Outer
.
scoped_allocator_adaptor::construct
template<class Ty, class... Atypes> void construct(Ty *ptr, Atypes&&... args); template<class Ty1, class Ty2, class... Atypes1, class... Atypes2> void construct(pair<Ty1, Ty2> *ptr, piecewise_construct_t, tuple<Atypes1&&...> first, tuple<Atypes1&&...> second); template<class Ty1, class Ty2> void construct(pair<Ty1, Ty2> *ptr); template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, class Uy1&& first, class Uy2&& second); template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, const pair<Uy1, Uy2>& right); template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, pair<Uy1, Uy2>&& right);
The member function:
template<class Ty, class... Atypes> void construct(Ty *ptr, Atypes&&... args);
constructs the object at ptr
by calling
Outermost_traits::construct(OUTERMOST(*this), ptr, xargs...)
,
where xargs...
is args...
modified in one of
three ways:
uses_allocator<Ty,
inner_allocator_type>
holds false,
then xargs...
is args...
.uses_allocator<Ty, inner_allocator_type>
holds true,
and is_constructible<Ty, allocator_arg_t, inner_allocator_type, args...>
holds true,
then xargs...
is allocator_arg, inner_allocator(), args...
.uses_allocator<Ty, inner_allocator_type>
holds true,
and is_constructible<Ty, args..., inner_allocator()>
holds true,
then xargs...
is args..., inner_allocator()
.The member function:
template<class Ty1, class Ty2, class... Atypes1, class... Atypes2> void construct(pair<Ty1, Ty2> *ptr, piecewise_construct_t, tuple<Atypes1&&...> first, tuple<Atypes1&&...> second);
constructs the pair object at ptr
by calling
Outermost_traits::construct(OUTERMOST(*this), &ptr->first, xargs...)
,
where xargs...
is first...
modified as above, and
Outermost_traits::construct(OUTERMOST(*this), &ptr->second, xargs...)
,
where xargs...
is second...
modified as above.
The member function:
template<class Ty1, class Ty2> void construct(pair<Ty1, Ty2> *ptr);
behaves the same as this->construct(ptr, piecewise_construct,
tuple<>, tuple<>)
.
The member function:
template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, class Uy1&& first, class Uy2&& second);
behaves the same as this->construct(ptr, piecewise_construct,
forward_as_tuple(std::forward<Uy1>(first),
forward_as_tuple(std::forward<Uy2>(second))
.
The member function:
template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, const pair<Uy1, Uy2>& right);
behaves the same as this->construct(ptr, piecewise_construct,
forward_as_tuple(right.first),
forward_as_tuple(right.second))
.
The member function:
template<class Ty1, class Ty2, class Uy1, class Uy2> void construct(pair<Ty1, Ty2> *ptr, pair<Uy1, Uy2>&& right);
behaves the same as this->construct(ptr, piecewise_construct,
forward_as_tuple(std::forward<Uy1>(right.first),
forward_as_tuple(std::forward<Uy2>(right.second))
.
scoped_allocator_adaptor::deallocate
void deallocate(pointer ptr, size_type count);
The member function calls
Outer_traits::deallocate(outer_allocator(), ptr, count)
.
scoped_allocator_adaptor::destroy
template<class Ty> void destroy(Ty *ptr);
The member function calls
Outermost_traits::destroy(OUTERMOST(*this), ptr)
.
scoped_allocator_adaptor::difference_type
typedef typename Outer_traits::difference_type difference_type;
The type is a synonym for the difference_type
associated with the allocator Outer
.
scoped_allocator_adaptor::inner_allocator
inner_allocator_type& inner_allocator() noexcept; const inner_allocator_type& inner_allocator() const noexcept;
The member function returns a reference to the (effective) stored object of
type inner_allocator_type
.
scoped_allocator_adaptor::inner_allocator_type
typedef T4 inner_allocator_type;
The type is a synonym for the (effective) type of the nested adaptor
scoped_allocator_adaptor<Inner...>
.
It is described here as a
synonym for the implementation-defined type T4
.
scoped_allocator_adaptor::max_size
size_type max_size();
The member function returns
Outer_traits::max_size(outer_allocator())
.
scoped_allocator_adaptor::outer_allocator
outer_allocator_type& outer_allocator() noexcept; const outer_allocator_type& outer_allocator() const noexcept;
The member function returns a reference to the stored (base) object of
type outer_allocator_type
.
scoped_allocator_adaptor::outer_allocator_type
typedef Outer outer_allocator_type;
The type is a synonym for the type of the (base) allocator
Outer
.
scoped_allocator_adaptor::pointer
typedef typename Outer_traits::pointer pointer;
The type is a synonym for the pointer
associated with the allocator Outer
.
scoped_allocator_adaptor::propagate_on_container_copy_assignment
typedef T1 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.
It is described here as a
synonym for the implementation-defined type T1
.
scoped_allocator_adaptor::propagate_on_container_move_assignment
typedef T2 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.
It is described here as a
synonym for the implementation-defined type T2
.
scoped_allocator_adaptor::propagate_on_container_swap
typedef T3 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.
It is described here as a
synonym for the implementation-defined type T3
.
scoped_allocator_adaptor::rebind
template<class Other> struct rebind { typedef Other_traits::rebind<Other> Other_alloc; typedef scoped_allocator_adaptor<Other_alloc, Inner...> other; };
The member template class defines the type
Outer::rebind<Other>::other
as a synonym for
scoped_allocator_adaptor<Other, Inner...>
.
scoped_allocator_adaptor::scoped_allocator_adaptor
scoped_allocator_adaptor(); scoped_allocator_adaptor(const scoped_allocator_adaptor& right) noexcept; template<class Outer2> scoped_allocator_adaptor( const scoped_allocator_adaptor<Outer2, Inner...>& right) noexcept; template<class Outer2> scoped_allocator_adaptor( scoped_allocator_adaptor<Outer2, Inner...>&& right) noexcept; template<class Outer2> scoped_allocator_adaptor(Outer2&& al, const Inner&... rest) noexcept;
The first constructor default constructs its stored allocator objects.
Each of the next three constructors constructs its stored allocator objects
from the corresponding objects in right
.
The last constructor constructs its stored allocator objects from the
corresponding arguments in the argument list.
scoped_allocator_adaptor::select_on_container_copy_construction
scoped_allocator_adaptor select_on_container_copy_construction();
The member function effectively returns:
scoped_allocator_adaptor( Outer_traits::select_on_container_copy_construction(*this), inner_allocator().select_on_container_copy_construction())
The result is a new scoped_allocator_adaptor
object
with each stored allocator object initialized by calling
al.select_on_container_copy_construction()
for the
corresponding allocator al
.
scoped_allocator_adaptor::size_type
typedef typename Outer_traits::size_type size_type;
The type is a synonym for the size_type
associated with the allocator Outer
.
scoped_allocator_adaptor::value_type
typedef typename Outer_traits::value_type value_type;
The type is a synonym for the value_type
associated with the allocator Outer
.
scoped_allocator_adaptor::void_pointer
typedef typename Outer_traits::void_pointer void_pointer;
The type is a synonym for the void_pointer
associated with the allocator Outer
.
See also the Table of Contents and the Index.
Copyright © 1992-2013 by Dinkumware, Ltd. All rights reserved.