tmp/tmp24pv6dmh/{from.md → to.md}
RENAMED
|
@@ -1,14 +1,19 @@
|
|
| 1 |
### Allocator traits <a id="allocator.traits">[[allocator.traits]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
The class template `allocator_traits` supplies a uniform interface to
|
| 4 |
all allocator types. An allocator cannot be a non-class type, however,
|
| 5 |
even if `allocator_traits` supplies the entire required interface.
|
| 6 |
|
| 7 |
[*Note 1*: Thus, it is always possible to create a derived class from
|
| 8 |
an allocator. — *end note*]
|
| 9 |
|
|
|
|
|
|
|
|
|
|
| 10 |
``` cpp
|
| 11 |
namespace std {
|
| 12 |
template<class Alloc> struct allocator_traits {
|
| 13 |
using allocator_type = Alloc;
|
| 14 |
|
|
@@ -31,10 +36,12 @@ namespace std {
|
|
| 31 |
template<class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
|
| 32 |
|
| 33 |
[[nodiscard]] static constexpr pointer allocate(Alloc& a, size_type n);
|
| 34 |
[[nodiscard]] static constexpr pointer allocate(Alloc& a, size_type n,
|
| 35 |
const_void_pointer hint);
|
|
|
|
|
|
|
| 36 |
|
| 37 |
static constexpr void deallocate(Alloc& a, pointer p, size_type n);
|
| 38 |
|
| 39 |
template<class T, class... Args>
|
| 40 |
static constexpr void construct(Alloc& a, T* p, Args&&... args);
|
|
@@ -153,10 +160,18 @@ arguments; otherwise, the instantiation of `rebind_alloc` is ill-formed.
|
|
| 153 |
```
|
| 154 |
|
| 155 |
*Returns:* `a.allocate(n, hint)` if that expression is well-formed;
|
| 156 |
otherwise, `a.allocate(n)`.
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
``` cpp
|
| 159 |
static constexpr void deallocate(Alloc& a, pointer p, size_type n);
|
| 160 |
```
|
| 161 |
|
| 162 |
*Effects:* Calls `a.deallocate(p, n)`.
|
|
@@ -192,5 +207,11 @@ static constexpr Alloc select_on_container_copy_construction(const Alloc& rhs);
|
|
| 192 |
```
|
| 193 |
|
| 194 |
*Returns:* `rhs.select_on_container_copy_construction()` if that
|
| 195 |
expression is well-formed; otherwise, `rhs`.
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
### Allocator traits <a id="allocator.traits">[[allocator.traits]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="allocator.traits.general">[[allocator.traits.general]]</a>
|
| 4 |
+
|
| 5 |
The class template `allocator_traits` supplies a uniform interface to
|
| 6 |
all allocator types. An allocator cannot be a non-class type, however,
|
| 7 |
even if `allocator_traits` supplies the entire required interface.
|
| 8 |
|
| 9 |
[*Note 1*: Thus, it is always possible to create a derived class from
|
| 10 |
an allocator. — *end note*]
|
| 11 |
|
| 12 |
+
If a program declares an explicit or partial specialization of
|
| 13 |
+
`allocator_traits`, the program is ill-formed, no diagnostic required.
|
| 14 |
+
|
| 15 |
``` cpp
|
| 16 |
namespace std {
|
| 17 |
template<class Alloc> struct allocator_traits {
|
| 18 |
using allocator_type = Alloc;
|
| 19 |
|
|
|
|
| 36 |
template<class T> using rebind_traits = allocator_traits<rebind_alloc<T>>;
|
| 37 |
|
| 38 |
[[nodiscard]] static constexpr pointer allocate(Alloc& a, size_type n);
|
| 39 |
[[nodiscard]] static constexpr pointer allocate(Alloc& a, size_type n,
|
| 40 |
const_void_pointer hint);
|
| 41 |
+
[[nodiscard]] static constexpr allocation_result<pointer, size_type>
|
| 42 |
+
allocate_at_least(Alloc& a, size_type n);
|
| 43 |
|
| 44 |
static constexpr void deallocate(Alloc& a, pointer p, size_type n);
|
| 45 |
|
| 46 |
template<class T, class... Args>
|
| 47 |
static constexpr void construct(Alloc& a, T* p, Args&&... args);
|
|
|
|
| 160 |
```
|
| 161 |
|
| 162 |
*Returns:* `a.allocate(n, hint)` if that expression is well-formed;
|
| 163 |
otherwise, `a.allocate(n)`.
|
| 164 |
|
| 165 |
+
``` cpp
|
| 166 |
+
[[nodiscard]] static constexpr allocation_result<pointer, size_type>
|
| 167 |
+
allocate_at_least(Alloc& a, size_type n);
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
*Returns:* `a.allocate_at_least(n)` if that expression is well-formed;
|
| 171 |
+
otherwise, `{a.allocate(n), n}`.
|
| 172 |
+
|
| 173 |
``` cpp
|
| 174 |
static constexpr void deallocate(Alloc& a, pointer p, size_type n);
|
| 175 |
```
|
| 176 |
|
| 177 |
*Effects:* Calls `a.deallocate(p, n)`.
|
|
|
|
| 207 |
```
|
| 208 |
|
| 209 |
*Returns:* `rhs.select_on_container_copy_construction()` if that
|
| 210 |
expression is well-formed; otherwise, `rhs`.
|
| 211 |
|
| 212 |
+
#### Other <a id="allocator.traits.other">[[allocator.traits.other]]</a>
|
| 213 |
+
|
| 214 |
+
The class template `allocation_result` has the template parameters, data
|
| 215 |
+
members, and special members specified above. It has no base classes or
|
| 216 |
+
members other than those specified.
|
| 217 |
+
|