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

147 lines
4.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[allocator.adaptor.members]
# 20 Memory management library [[mem]](./#mem)
## 20.6 Class template scoped_allocator_adaptor [[allocator.adaptor]](allocator.adaptor#members)
### 20.6.4 Members [allocator.adaptor.members]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8873)
In the construct member functions,*OUTERMOST*(x) is*OUTERMOST*(x.outer_allocator()) if
the expression x.outer_allocator() is
valid ([[temp.deduct]](temp.deduct "13.10.3Template argument deduction")) andx otherwise;*OUTERMOST_ALLOC_TRAITS*(x) isallocator_traits<remove_reference_t<decltype(*OUTERMOST*(x))>>[.](#1.sentence-1)
[*Note [1](#note-1)*:
*OUTERMOST*(x) and*OUTERMOST_ALLOC_TRAITS*(x) are recursive operations[.](#1.sentence-2)
It
is incumbent upon the definition of outer_allocator() to ensure that the
recursion terminates[.](#1.sentence-3)
It will terminate for all instantiations ofscoped_allocator_adaptor[.](#1.sentence-4)
— *end note*]
[🔗](#lib:inner_allocator,scoped_allocator_adaptor)
`inner_allocator_type& inner_allocator() noexcept;
const inner_allocator_type& inner_allocator() const noexcept;
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8897)
*Returns*: *this if sizeof...(InnerAllocs) is zero; otherwise,inner[.](#2.sentence-1)
[🔗](#lib:outer_allocator,scoped_allocator_adaptor)
`outer_allocator_type& outer_allocator() noexcept;
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8909)
*Returns*: static_cast<OuterAlloc&>(*this)[.](#3.sentence-1)
[🔗](#lib:outer_allocator,scoped_allocator_adaptor_)
`const outer_allocator_type& outer_allocator() const noexcept;
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8920)
*Returns*: static_cast<const OuterAlloc&>(*this)[.](#4.sentence-1)
[🔗](#lib:allocate,scoped_allocator_adaptor)
`pointer allocate(size_type n);
`
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8931)
*Returns*: allocator_traits<OuterAlloc>::allocate(outer_allocator(), n)[.](#5.sentence-1)
[🔗](#lib:allocate,scoped_allocator_adaptor_)
`pointer allocate(size_type n, const_void_pointer hint);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8942)
*Returns*: allocator_traits<OuterAlloc>::allocate(outer_allocator(), n, hint)[.](#6.sentence-1)
[🔗](#lib:deallocate,scoped_allocator_adaptor)
`void deallocate(pointer p, size_type n) noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8953)
*Effects*: As if by:allocator_traits<OuterAlloc>::deallocate(outer_allocator(), p, n);
[🔗](#lib:max_size,scoped_allocator_adaptor)
`size_type max_size() const;
`
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8965)
*Returns*: allocator_traits<OuterAlloc>::max_size(outer_allocator())[.](#8.sentence-1)
[🔗](#lib:construct,scoped_allocator_adaptor)
`template<class T, class... Args>
void construct(T* p, Args&&... args);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8977)
*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<T>(inner_allocator(),
std::forward<Args>(args)...));
[🔗](#lib:destroy,scoped_allocator_adaptor)
`template<class T>
void destroy(T* p);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L8998)
*Effects*: Calls *OUTERMOST_ALLOC_TRAITS*(*this)::destroy(*OUTERMOST*(*this), p)[.](#10.sentence-1)
[🔗](#lib:select_on_container_copy_construction,scoped_allocator_adaptor)
`scoped_allocator_adaptor select_on_container_copy_construction() const;
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L9009)
*Returns*: A new scoped_allocator_adaptor object
where each allocator a1 within the adaptor
is initialized withallocator_traits<A1>::select_on_container_copy_construction(a2),
where A1 is the type of a1 anda2 is the corresponding allocator in *this[.](#11.sentence-1)