109 lines
3.2 KiB
Markdown
109 lines
3.2 KiB
Markdown
[allocator.traits.members]
|
||
|
||
# 20 Memory management library [[mem]](./#mem)
|
||
|
||
## 20.2 Memory [[memory]](memory#allocator.traits.members)
|
||
|
||
### 20.2.9 Allocator traits [[allocator.traits]](allocator.traits#members)
|
||
|
||
#### 20.2.9.3 Static member functions [allocator.traits.members]
|
||
|
||
[ð](#lib:allocate,allocator_traits)
|
||
|
||
`static constexpr pointer allocate(Alloc& a, size_type n);
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1851)
|
||
|
||
*Returns*: a.allocate(n)[.](#1.sentence-1)
|
||
|
||
[ð](#lib:allocate,allocator_traits_)
|
||
|
||
`static constexpr pointer allocate(Alloc& a, size_type n, const_void_pointer hint);
|
||
`
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1862)
|
||
|
||
*Returns*: a.allocate(n, hint) if that expression is well-formed; otherwise, a.allocate(n)[.](#2.sentence-1)
|
||
|
||
[ð](#lib:allocate_at_least,allocator_traits)
|
||
|
||
`static constexpr allocation_result<pointer, size_type> allocate_at_least(Alloc& a, size_type n);
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1873)
|
||
|
||
*Returns*: a.allocate_at_least(n) if that expression is well-formed;
|
||
otherwise, {a.allocate(n), n}[.](#3.sentence-1)
|
||
|
||
[ð](#lib:deallocate,allocator_traits)
|
||
|
||
`static constexpr void deallocate(Alloc& a, pointer p, size_type n);
|
||
`
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1885)
|
||
|
||
*Effects*: Calls a.deallocate(p, n)[.](#4.sentence-1)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1889)
|
||
|
||
*Throws*: Nothing[.](#5.sentence-1)
|
||
|
||
[ð](#lib:construct,allocator_traits)
|
||
|
||
`template<class T, class... Args>
|
||
static constexpr void construct(Alloc& a, T* p, Args&&... args);
|
||
`
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1901)
|
||
|
||
*Effects*: Calls a.construct(p, std::forward<Args>(args)...) if that call is well-formed;
|
||
otherwise, invokes construct_at(p, std::forward<Args>(args)...)[.](#6.sentence-1)
|
||
|
||
[ð](#lib:destroy,allocator_traits)
|
||
|
||
`template<class T>
|
||
static constexpr void destroy(Alloc& a, T* p);
|
||
`
|
||
|
||
[7](#7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1915)
|
||
|
||
*Effects*: Calls a.destroy(p) if that call is well-formed; otherwise, invokesdestroy_at(p)[.](#7.sentence-1)
|
||
|
||
[ð](#lib:max_size,allocator_traits)
|
||
|
||
`static constexpr size_type max_size(const Alloc& a) noexcept;
|
||
`
|
||
|
||
[8](#8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1927)
|
||
|
||
*Returns*: a.max_size() if that expression is well-formed; otherwise,numeric_limits<size_type>::max() / sizeof(value_type)[.](#8.sentence-1)
|
||
|
||
[ð](#lib:select_on_container_copy_construction,allocator_traits)
|
||
|
||
`static constexpr Alloc select_on_container_copy_construction(const Alloc& rhs);
|
||
`
|
||
|
||
[9](#9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L1939)
|
||
|
||
*Returns*: rhs.select_on_container_copy_construction() if that expression is
|
||
well-formed; otherwise, rhs[.](#9.sentence-1)
|