Files
cppdraft_translate/cppdraft/allocator/adaptor/members.md
2025-10-25 03:02:53 +03:00

4.5 KiB
Raw Blame History

[allocator.adaptor.members]

20 Memory management library [mem]

20.6 Class template scoped_allocator_adaptor [allocator.adaptor]

20.6.4 Members [allocator.adaptor.members]

1

#

In the construct member functions,OUTERMOST(x) isOUTERMOST(x.outer_allocator()) if the expression x.outer_allocator() is valid ([temp.deduct]) andx otherwise;OUTERMOST_ALLOC_TRAITS(x) isallocator_traits<remove_reference_t<decltype(OUTERMOST(x))>>.

[Note 1:

OUTERMOST(x) andOUTERMOST_ALLOC_TRAITS(x) are recursive operations.

It is incumbent upon the definition of outer_allocator() to ensure that the recursion terminates.

It will terminate for all instantiations ofscoped_allocator_adaptor.

— end note]

🔗

inner_allocator_type& inner_allocator() noexcept; const inner_allocator_type& inner_allocator() const noexcept;

2

#

Returns: *this if sizeof...(InnerAllocs) is zero; otherwise,inner.

🔗

outer_allocator_type& outer_allocator() noexcept;

3

#

Returns: static_cast<OuterAlloc&>(*this).

🔗

const outer_allocator_type& outer_allocator() const noexcept;

4

#

Returns: static_cast<const OuterAlloc&>(*this).

🔗

pointer allocate(size_type n);

5

#

Returns: allocator_traits::allocate(outer_allocator(), n).

🔗

pointer allocate(size_type n, const_void_pointer hint);

6

#

Returns: allocator_traits::allocate(outer_allocator(), n, hint).

🔗

void deallocate(pointer p, size_type n) noexcept;

7

#

Effects: As if by:allocator_traits::deallocate(outer_allocator(), p, n);

🔗

size_type max_size() const;

8

#

Returns: allocator_traits::max_size(outer_allocator()).

🔗

template<class T, class... Args> void construct(T* p, Args&&... args);

9

#

Effects: Equivalent to:apply([p, this](auto&&... newargs) {OUTERMOST_ALLOC_TRAITS(*this)::construct(OUTERMOST(*this), p, std::forward<decltype(newargs)>(newargs)...); }, uses_allocator_construction_args(inner_allocator(), std::forward(args)...));

🔗

template<class T> void destroy(T* p);

10

#

Effects: Calls OUTERMOST_ALLOC_TRAITS(*this)::destroy(OUTERMOST(*this), p).

🔗

scoped_allocator_adaptor select_on_container_copy_construction() const;

11

#

Returns: A new scoped_allocator_adaptor object where each allocator a1 within the adaptor is initialized withallocator_traits::select_on_container_copy_construction(a2), where A1 is the type of a1 anda2 is the corresponding allocator in *this.