- tmp/tmpk9o7z6a_/{from.md → to.md} +39 -197
tmp/tmpk9o7z6a_/{from.md → to.md}
RENAMED
|
@@ -1,24 +1,25 @@
|
|
| 1 |
## Class template `scoped_allocator_adaptor` <a id="allocator.adaptor">[[allocator.adaptor]]</a>
|
| 2 |
|
| 3 |
### Header `<scoped_allocator>` synopsis <a id="allocator.adaptor.syn">[[allocator.adaptor.syn]]</a>
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
-
|
|
|
|
| 7 |
template<class OuterAlloc, class... InnerAlloc>
|
| 8 |
class scoped_allocator_adaptor;
|
|
|
|
|
|
|
| 9 |
template<class OuterA1, class OuterA2, class... InnerAllocs>
|
| 10 |
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 11 |
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
| 12 |
-
|
| 13 |
-
bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 14 |
-
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
| 15 |
```
|
| 16 |
|
| 17 |
The class template `scoped_allocator_adaptor` is an allocator template
|
| 18 |
-
that specifies
|
| 19 |
-
container (as any other allocator does) and also specifies an inner
|
| 20 |
allocator resource to be passed to the constructor of every element
|
| 21 |
within the container. This adaptor is instantiated with one outer and
|
| 22 |
zero or more inner allocator types. If instantiated with only one
|
| 23 |
allocator type, the inner allocator becomes the
|
| 24 |
`scoped_allocator_adaptor` itself, thus using the same allocator
|
|
@@ -42,10 +43,11 @@ namespace std {
|
|
| 42 |
template<class OuterAlloc, class... InnerAllocs>
|
| 43 |
class scoped_allocator_adaptor : public OuterAlloc {
|
| 44 |
private:
|
| 45 |
using OuterTraits = allocator_traits<OuterAlloc>; // exposition only
|
| 46 |
scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only
|
|
|
|
| 47 |
public:
|
| 48 |
using outer_allocator_type = OuterAlloc;
|
| 49 |
using inner_allocator_type = see below;
|
| 50 |
|
| 51 |
using value_type = typename OuterTraits::value_type;
|
|
@@ -59,12 +61,11 @@ namespace std {
|
|
| 59 |
using propagate_on_container_copy_assignment = see below;
|
| 60 |
using propagate_on_container_move_assignment = see below;
|
| 61 |
using propagate_on_container_swap = see below;
|
| 62 |
using is_always_equal = see below;
|
| 63 |
|
| 64 |
-
template
|
| 65 |
-
struct rebind {
|
| 66 |
using other = scoped_allocator_adaptor<
|
| 67 |
OuterTraits::template rebind_alloc<Tp>, InnerAllocs...>;
|
| 68 |
};
|
| 69 |
|
| 70 |
scoped_allocator_adaptor();
|
|
@@ -90,49 +91,31 @@ namespace std {
|
|
| 90 |
inner_allocator_type& inner_allocator() noexcept;
|
| 91 |
const inner_allocator_type& inner_allocator() const noexcept;
|
| 92 |
outer_allocator_type& outer_allocator() noexcept;
|
| 93 |
const outer_allocator_type& outer_allocator() const noexcept;
|
| 94 |
|
| 95 |
-
pointer allocate(size_type n);
|
| 96 |
-
pointer allocate(size_type n, const_void_pointer hint);
|
| 97 |
void deallocate(pointer p, size_type n);
|
| 98 |
size_type max_size() const;
|
| 99 |
|
| 100 |
template<class T, class... Args>
|
| 101 |
void construct(T* p, Args&&... args);
|
| 102 |
-
template <class T1, class T2, class... Args1, class... Args2>
|
| 103 |
-
void construct(pair<T1, T2>* p, piecewise_construct_t,
|
| 104 |
-
tuple<Args1...> x, tuple<Args2...> y);
|
| 105 |
-
template <class T1, class T2>
|
| 106 |
-
void construct(pair<T1, T2>* p);
|
| 107 |
-
template <class T1, class T2, class U, class V>
|
| 108 |
-
void construct(pair<T1, T2>* p, U&& x, V&& y);
|
| 109 |
-
template <class T1, class T2, class U, class V>
|
| 110 |
-
void construct(pair<T1, T2>* p, const pair<U, V>& x);
|
| 111 |
-
template <class T1, class T2, class U, class V>
|
| 112 |
-
void construct(pair<T1, T2>* p, pair<U, V>&& x);
|
| 113 |
|
| 114 |
template<class T>
|
| 115 |
void destroy(T* p);
|
| 116 |
|
| 117 |
scoped_allocator_adaptor select_on_container_copy_construction() const;
|
| 118 |
};
|
| 119 |
|
| 120 |
template<class OuterAlloc, class... InnerAllocs>
|
| 121 |
scoped_allocator_adaptor(OuterAlloc, InnerAllocs...)
|
| 122 |
-> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
|
| 123 |
-
|
| 124 |
-
template <class OuterA1, class OuterA2, class... InnerAllocs>
|
| 125 |
-
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 126 |
-
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
| 127 |
-
template <class OuterA1, class OuterA2, class... InnerAllocs>
|
| 128 |
-
bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 129 |
-
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
| 130 |
}
|
| 131 |
```
|
| 132 |
|
| 133 |
-
###
|
| 134 |
|
| 135 |
``` cpp
|
| 136 |
using inner_allocator_type = see below;
|
| 137 |
```
|
| 138 |
|
|
@@ -173,33 +156,31 @@ using is_always_equal = see below;
|
|
| 173 |
|
| 174 |
*Type:* `true_type` if `allocator_traits<A>::is_always_equal::value` is
|
| 175 |
`true` for every `A` in the set of `OuterAlloc` and `InnerAllocs...`;
|
| 176 |
otherwise, `false_type`.
|
| 177 |
|
| 178 |
-
###
|
| 179 |
|
| 180 |
``` cpp
|
| 181 |
scoped_allocator_adaptor();
|
| 182 |
```
|
| 183 |
|
| 184 |
*Effects:* Value-initializes the `OuterAlloc` base class and the `inner`
|
| 185 |
allocator object.
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
template<class OuterA2>
|
| 189 |
-
scoped_allocator_adaptor(OuterA2&& outerAlloc,
|
| 190 |
-
const InnerAllocs&... innerAllocs) noexcept;
|
| 191 |
```
|
| 192 |
|
|
|
|
|
|
|
| 193 |
*Effects:* Initializes the `OuterAlloc` base class with
|
| 194 |
`std::forward<OuterA2>(outerAlloc)` and `inner` with `innerAllocs...`
|
| 195 |
(hence recursively initializing each allocator within the adaptor with
|
| 196 |
the corresponding allocator from the argument list).
|
| 197 |
|
| 198 |
-
*Remarks:* This constructor shall not participate in overload resolution
|
| 199 |
-
unless `is_constructible_v<OuterAlloc, OuterA2>` is `true`.
|
| 200 |
-
|
| 201 |
``` cpp
|
| 202 |
scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
|
| 203 |
```
|
| 204 |
|
| 205 |
*Effects:* Initializes each allocator within the adaptor with the
|
|
@@ -212,38 +193,36 @@ scoped_allocator_adaptor(scoped_allocator_adaptor&& other) noexcept;
|
|
| 212 |
*Effects:* Move constructs each allocator within the adaptor with the
|
| 213 |
corresponding allocator from `other`.
|
| 214 |
|
| 215 |
``` cpp
|
| 216 |
template<class OuterA2>
|
| 217 |
-
scoped_allocator_adaptor(
|
| 218 |
-
|
| 219 |
```
|
| 220 |
|
|
|
|
|
|
|
|
|
|
| 221 |
*Effects:* Initializes each allocator within the adaptor with the
|
| 222 |
corresponding allocator from `other`.
|
| 223 |
|
| 224 |
-
*Remarks:* This constructor shall not participate in overload resolution
|
| 225 |
-
unless `is_constructible_v<OuterAlloc, const OuterA2&>` is `true`.
|
| 226 |
-
|
| 227 |
``` cpp
|
| 228 |
template<class OuterA2>
|
| 229 |
-
scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2,
|
| 230 |
-
InnerAllocs...>&& other) noexcept;
|
| 231 |
```
|
| 232 |
|
|
|
|
|
|
|
| 233 |
*Effects:* Initializes each allocator within the adaptor with the
|
| 234 |
corresponding allocator rvalue from `other`.
|
| 235 |
|
| 236 |
-
|
| 237 |
-
unless `is_constructible_v<OuterAlloc, OuterA2>` is `true`.
|
| 238 |
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
`OUTERMOST(x.outer_allocator())` otherwise; `OUTERMOST_ALLOC_TRAITS(x)`
|
| 244 |
-
is `allocator_traits<decltype(OUTERMOST(x))>`.
|
| 245 |
|
| 246 |
[*Note 1*: `OUTERMOST(x)` and `OUTERMOST_ALLOC_TRAITS(x)` are recursive
|
| 247 |
operations. It is incumbent upon the definition of `outer_allocator()`
|
| 248 |
to ensure that the recursion terminates. It will terminate for all
|
| 249 |
instantiations of `scoped_allocator_adaptor`. — *end note*]
|
|
@@ -267,18 +246,18 @@ const outer_allocator_type& outer_allocator() const noexcept;
|
|
| 267 |
```
|
| 268 |
|
| 269 |
*Returns:* `static_cast<const OuterAlloc&>(*this)`.
|
| 270 |
|
| 271 |
``` cpp
|
| 272 |
-
pointer allocate(size_type n);
|
| 273 |
```
|
| 274 |
|
| 275 |
*Returns:*
|
| 276 |
`allocator_traits<OuterAlloc>::allocate(outer_allocator(), n)`.
|
| 277 |
|
| 278 |
``` cpp
|
| 279 |
-
pointer allocate(size_type n, const_void_pointer hint);
|
| 280 |
```
|
| 281 |
|
| 282 |
*Returns:*
|
| 283 |
`allocator_traits<OuterAlloc>::allocate(outer_allocator(), n, hint)`.
|
| 284 |
|
|
@@ -298,149 +277,20 @@ size_type max_size() const;
|
|
| 298 |
``` cpp
|
| 299 |
template<class T, class... Args>
|
| 300 |
void construct(T* p, Args&&... args);
|
| 301 |
```
|
| 302 |
|
| 303 |
-
*Effects:*
|
| 304 |
-
|
| 305 |
-
- If `uses_allocator_v<T, inner_allocator_type>` is `false` and
|
| 306 |
-
`is_constructible_v<T,`
|
| 307 |
-
`Args...>` is `true`, calls:
|
| 308 |
-
``` cpp
|
| 309 |
-
OUTERMOST_ALLOC_TRAITS(*this)::construct(
|
| 310 |
-
OUTERMOST(*this), p, std::forward<Args>(args)...)
|
| 311 |
-
```
|
| 312 |
-
- Otherwise, if `uses_allocator_v<T, inner_allocator_type>` is `true`
|
| 313 |
-
and
|
| 314 |
-
`is_constructible_v<T, allocator_arg_t, inner_allocator_type&, Args...>`
|
| 315 |
-
is `true`, calls:
|
| 316 |
-
``` cpp
|
| 317 |
-
OUTERMOST_ALLOC_TRAITS(*this)::construct(
|
| 318 |
-
OUTERMOST(*this), p, allocator_arg, inner_allocator(), std::forward<Args>(args)...)
|
| 319 |
-
```
|
| 320 |
-
- Otherwise, if `uses_allocator_v<T, inner_allocator_type>` is `true`
|
| 321 |
-
and `is_constructible_v<T, Args..., inner_allocator_type&>` is `true`,
|
| 322 |
-
calls:
|
| 323 |
-
``` cpp
|
| 324 |
-
OUTERMOST_ALLOC_TRAITS(*this)::construct(
|
| 325 |
-
OUTERMOST(*this), p, std::forward<Args>(args)..., inner_allocator())
|
| 326 |
-
```
|
| 327 |
-
- Otherwise, the program is ill-formed. \[*Note 2*: An error will result
|
| 328 |
-
if `uses_allocator` evaluates to `true` but the specific constructor
|
| 329 |
-
does not take an allocator. This definition prevents a silent failure
|
| 330 |
-
to pass an inner allocator to a contained element. — *end note*]
|
| 331 |
-
|
| 332 |
-
``` cpp
|
| 333 |
-
template <class T1, class T2, class... Args1, class... Args2>
|
| 334 |
-
void construct(pair<T1, T2>* p, piecewise_construct_t,
|
| 335 |
-
tuple<Args1...> x, tuple<Args2...> y);
|
| 336 |
-
```
|
| 337 |
-
|
| 338 |
-
*Requires:* all of the types in `Args1` and `Args2` shall be
|
| 339 |
-
`CopyConstructible` (Table [[tab:copyconstructible]]).
|
| 340 |
-
|
| 341 |
-
*Effects:* Constructs a `tuple` object `xprime` from `x` by the
|
| 342 |
-
following rules:
|
| 343 |
-
|
| 344 |
-
- If `uses_allocator_v<T1, inner_allocator_type>` is `false` and
|
| 345 |
-
`is_constructible_v<T1,`
|
| 346 |
-
`Args1...>` is `true`, then `xprime` is `x`.
|
| 347 |
-
- Otherwise, if `uses_allocator_v<T1, inner_allocator_type>` is `true`
|
| 348 |
-
and
|
| 349 |
-
`is_constructible_v<T1, allocator_arg_t, inner_allocator_type&, Args1...>`
|
| 350 |
-
is `true`, then `xprime` is:
|
| 351 |
-
``` cpp
|
| 352 |
-
tuple_cat(
|
| 353 |
-
tuple<allocator_arg_t, inner_allocator_type&>(allocator_arg, inner_allocator()),
|
| 354 |
-
std::move(x))
|
| 355 |
-
```
|
| 356 |
-
- Otherwise, if `uses_allocator_v<T1, inner_allocator_type>` is `true`
|
| 357 |
-
and `is_constructible_v<T1, Args1..., inner_allocator_type&>` is
|
| 358 |
-
`true`, then `xprime` is:
|
| 359 |
-
``` cpp
|
| 360 |
-
tuple_cat(std::move(x), tuple<inner_allocator_type&>(inner_allocator()))
|
| 361 |
-
```
|
| 362 |
-
- Otherwise, the program is ill-formed.
|
| 363 |
-
|
| 364 |
-
and constructs a `tuple` object `yprime` from `y` by the following
|
| 365 |
-
rules:
|
| 366 |
-
|
| 367 |
-
- If `uses_allocator_v<T2, inner_allocator_type>` is `false` and
|
| 368 |
-
`is_constructible_v<T2,`
|
| 369 |
-
`Args2...>` is `true`, then `yprime` is `y`.
|
| 370 |
-
- Otherwise, if `uses_allocator_v<T2, inner_allocator_type>` is `true`
|
| 371 |
-
and
|
| 372 |
-
`is_constructible_v<T2, allocator_arg_t, inner_allocator_type&, Args2...>`
|
| 373 |
-
is `true`, then `yprime` is:
|
| 374 |
-
``` cpp
|
| 375 |
-
tuple_cat(
|
| 376 |
-
tuple<allocator_arg_t, inner_allocator_type&>(allocator_arg, inner_allocator()),
|
| 377 |
-
std::move(y))
|
| 378 |
-
```
|
| 379 |
-
- Otherwise, if `uses_allocator_v<T2, inner_allocator_type>` is `true`
|
| 380 |
-
and `is_constructible_v<T2, Args2..., inner_allocator_type&>` is
|
| 381 |
-
`true`, then `yprime` is:
|
| 382 |
-
``` cpp
|
| 383 |
-
tuple_cat(std::move(y), tuple<inner_allocator_type&>(inner_allocator()))
|
| 384 |
-
```
|
| 385 |
-
- Otherwise, the program is ill-formed.
|
| 386 |
-
|
| 387 |
-
then calls:
|
| 388 |
-
|
| 389 |
-
``` cpp
|
| 390 |
-
OUTERMOST_ALLOC_TRAITS(*this)::construct(
|
| 391 |
-
OUTERMOST(*this), p, piecewise_construct, std::move(xprime), std::move(yprime))
|
| 392 |
-
```
|
| 393 |
-
|
| 394 |
-
``` cpp
|
| 395 |
-
template <class T1, class T2>
|
| 396 |
-
void construct(pair<T1, T2>* p);
|
| 397 |
-
```
|
| 398 |
-
|
| 399 |
-
*Effects:* Equivalent to:
|
| 400 |
-
|
| 401 |
-
``` cpp
|
| 402 |
-
construct(p, piecewise_construct, tuple<>(), tuple<>());
|
| 403 |
-
```
|
| 404 |
-
|
| 405 |
-
``` cpp
|
| 406 |
-
template <class T1, class T2, class U, class V>
|
| 407 |
-
void construct(pair<T1, T2>* p, U&& x, V&& y);
|
| 408 |
-
```
|
| 409 |
-
|
| 410 |
-
*Effects:* Equivalent to:
|
| 411 |
-
|
| 412 |
-
``` cpp
|
| 413 |
-
construct(p, piecewise_construct,
|
| 414 |
-
forward_as_tuple(std::forward<U>(x)),
|
| 415 |
-
forward_as_tuple(std::forward<V>(y)));
|
| 416 |
-
```
|
| 417 |
-
|
| 418 |
-
``` cpp
|
| 419 |
-
template <class T1, class T2, class U, class V>
|
| 420 |
-
void construct(pair<T1, T2>* p, const pair<U, V>& x);
|
| 421 |
-
```
|
| 422 |
-
|
| 423 |
*Effects:* Equivalent to:
|
| 424 |
|
| 425 |
``` cpp
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
void construct(pair<T1, T2>* p, pair<U, V>&& x);
|
| 434 |
-
```
|
| 435 |
-
|
| 436 |
-
*Effects:* Equivalent to:
|
| 437 |
-
|
| 438 |
-
``` cpp
|
| 439 |
-
construct(p, piecewise_construct,
|
| 440 |
-
forward_as_tuple(std::forward<U>(x.first)),
|
| 441 |
-
forward_as_tuple(std::forward<V>(x.second)));
|
| 442 |
```
|
| 443 |
|
| 444 |
``` cpp
|
| 445 |
template<class T>
|
| 446 |
void destroy(T* p);
|
|
@@ -456,11 +306,11 @@ scoped_allocator_adaptor select_on_container_copy_construction() const;
|
|
| 456 |
*Returns:* A new `scoped_allocator_adaptor` object where each allocator
|
| 457 |
`A` in the adaptor is initialized from the result of calling
|
| 458 |
`allocator_traits<A>::select_on_container_copy_construction()` on the
|
| 459 |
corresponding allocator in `*this`.
|
| 460 |
|
| 461 |
-
###
|
| 462 |
|
| 463 |
``` cpp
|
| 464 |
template<class OuterA1, class OuterA2, class... InnerAllocs>
|
| 465 |
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 466 |
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
|
@@ -476,13 +326,5 @@ otherwise
|
|
| 476 |
|
| 477 |
``` cpp
|
| 478 |
a.outer_allocator() == b.outer_allocator() && a.inner_allocator() == b.inner_allocator()
|
| 479 |
```
|
| 480 |
|
| 481 |
-
``` cpp
|
| 482 |
-
template <class OuterA1, class OuterA2, class... InnerAllocs>
|
| 483 |
-
bool operator!=(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 484 |
-
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
| 485 |
-
```
|
| 486 |
-
|
| 487 |
-
*Returns:* `!(a == b)`.
|
| 488 |
-
|
|
|
|
| 1 |
## Class template `scoped_allocator_adaptor` <a id="allocator.adaptor">[[allocator.adaptor]]</a>
|
| 2 |
|
| 3 |
### Header `<scoped_allocator>` synopsis <a id="allocator.adaptor.syn">[[allocator.adaptor.syn]]</a>
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
+
namespace std {
|
| 7 |
+
// class template scoped allocator adaptor
|
| 8 |
template<class OuterAlloc, class... InnerAlloc>
|
| 9 |
class scoped_allocator_adaptor;
|
| 10 |
+
|
| 11 |
+
// [scoped.adaptor.operators], scoped allocator operators
|
| 12 |
template<class OuterA1, class OuterA2, class... InnerAllocs>
|
| 13 |
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 14 |
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
| 15 |
+
}
|
|
|
|
|
|
|
| 16 |
```
|
| 17 |
|
| 18 |
The class template `scoped_allocator_adaptor` is an allocator template
|
| 19 |
+
that specifies an allocator resource (the outer allocator) to be used by
|
| 20 |
+
a container (as any other allocator does) and also specifies an inner
|
| 21 |
allocator resource to be passed to the constructor of every element
|
| 22 |
within the container. This adaptor is instantiated with one outer and
|
| 23 |
zero or more inner allocator types. If instantiated with only one
|
| 24 |
allocator type, the inner allocator becomes the
|
| 25 |
`scoped_allocator_adaptor` itself, thus using the same allocator
|
|
|
|
| 43 |
template<class OuterAlloc, class... InnerAllocs>
|
| 44 |
class scoped_allocator_adaptor : public OuterAlloc {
|
| 45 |
private:
|
| 46 |
using OuterTraits = allocator_traits<OuterAlloc>; // exposition only
|
| 47 |
scoped_allocator_adaptor<InnerAllocs...> inner; // exposition only
|
| 48 |
+
|
| 49 |
public:
|
| 50 |
using outer_allocator_type = OuterAlloc;
|
| 51 |
using inner_allocator_type = see below;
|
| 52 |
|
| 53 |
using value_type = typename OuterTraits::value_type;
|
|
|
|
| 61 |
using propagate_on_container_copy_assignment = see below;
|
| 62 |
using propagate_on_container_move_assignment = see below;
|
| 63 |
using propagate_on_container_swap = see below;
|
| 64 |
using is_always_equal = see below;
|
| 65 |
|
| 66 |
+
template<class Tp> struct rebind {
|
|
|
|
| 67 |
using other = scoped_allocator_adaptor<
|
| 68 |
OuterTraits::template rebind_alloc<Tp>, InnerAllocs...>;
|
| 69 |
};
|
| 70 |
|
| 71 |
scoped_allocator_adaptor();
|
|
|
|
| 91 |
inner_allocator_type& inner_allocator() noexcept;
|
| 92 |
const inner_allocator_type& inner_allocator() const noexcept;
|
| 93 |
outer_allocator_type& outer_allocator() noexcept;
|
| 94 |
const outer_allocator_type& outer_allocator() const noexcept;
|
| 95 |
|
| 96 |
+
[[nodiscard]] pointer allocate(size_type n);
|
| 97 |
+
[[nodiscard]] pointer allocate(size_type n, const_void_pointer hint);
|
| 98 |
void deallocate(pointer p, size_type n);
|
| 99 |
size_type max_size() const;
|
| 100 |
|
| 101 |
template<class T, class... Args>
|
| 102 |
void construct(T* p, Args&&... args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
template<class T>
|
| 105 |
void destroy(T* p);
|
| 106 |
|
| 107 |
scoped_allocator_adaptor select_on_container_copy_construction() const;
|
| 108 |
};
|
| 109 |
|
| 110 |
template<class OuterAlloc, class... InnerAllocs>
|
| 111 |
scoped_allocator_adaptor(OuterAlloc, InnerAllocs...)
|
| 112 |
-> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
```
|
| 115 |
|
| 116 |
+
### Member types <a id="allocator.adaptor.types">[[allocator.adaptor.types]]</a>
|
| 117 |
|
| 118 |
``` cpp
|
| 119 |
using inner_allocator_type = see below;
|
| 120 |
```
|
| 121 |
|
|
|
|
| 156 |
|
| 157 |
*Type:* `true_type` if `allocator_traits<A>::is_always_equal::value` is
|
| 158 |
`true` for every `A` in the set of `OuterAlloc` and `InnerAllocs...`;
|
| 159 |
otherwise, `false_type`.
|
| 160 |
|
| 161 |
+
### Constructors <a id="allocator.adaptor.cnstr">[[allocator.adaptor.cnstr]]</a>
|
| 162 |
|
| 163 |
``` cpp
|
| 164 |
scoped_allocator_adaptor();
|
| 165 |
```
|
| 166 |
|
| 167 |
*Effects:* Value-initializes the `OuterAlloc` base class and the `inner`
|
| 168 |
allocator object.
|
| 169 |
|
| 170 |
``` cpp
|
| 171 |
template<class OuterA2>
|
| 172 |
+
scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs&... innerAllocs) noexcept;
|
|
|
|
| 173 |
```
|
| 174 |
|
| 175 |
+
*Constraints:* `is_constructible_v<OuterAlloc, OuterA2>` is `true`.
|
| 176 |
+
|
| 177 |
*Effects:* Initializes the `OuterAlloc` base class with
|
| 178 |
`std::forward<OuterA2>(outerAlloc)` and `inner` with `innerAllocs...`
|
| 179 |
(hence recursively initializing each allocator within the adaptor with
|
| 180 |
the corresponding allocator from the argument list).
|
| 181 |
|
|
|
|
|
|
|
|
|
|
| 182 |
``` cpp
|
| 183 |
scoped_allocator_adaptor(const scoped_allocator_adaptor& other) noexcept;
|
| 184 |
```
|
| 185 |
|
| 186 |
*Effects:* Initializes each allocator within the adaptor with the
|
|
|
|
| 193 |
*Effects:* Move constructs each allocator within the adaptor with the
|
| 194 |
corresponding allocator from `other`.
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
template<class OuterA2>
|
| 198 |
+
scoped_allocator_adaptor(
|
| 199 |
+
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other) noexcept;
|
| 200 |
```
|
| 201 |
|
| 202 |
+
*Constraints:* `is_constructible_v<OuterAlloc, const OuterA2&>` is
|
| 203 |
+
`true`.
|
| 204 |
+
|
| 205 |
*Effects:* Initializes each allocator within the adaptor with the
|
| 206 |
corresponding allocator from `other`.
|
| 207 |
|
|
|
|
|
|
|
|
|
|
| 208 |
``` cpp
|
| 209 |
template<class OuterA2>
|
| 210 |
+
scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other) noexcept;
|
|
|
|
| 211 |
```
|
| 212 |
|
| 213 |
+
*Constraints:* `is_constructible_v<OuterAlloc, OuterA2>` is `true`.
|
| 214 |
+
|
| 215 |
*Effects:* Initializes each allocator within the adaptor with the
|
| 216 |
corresponding allocator rvalue from `other`.
|
| 217 |
|
| 218 |
+
### Members <a id="allocator.adaptor.members">[[allocator.adaptor.members]]</a>
|
|
|
|
| 219 |
|
| 220 |
+
In the `construct` member functions, `OUTERMOST(x)` is
|
| 221 |
+
`OUTERMOST(x.outer_allocator())` if the expression `x.outer_allocator()`
|
| 222 |
+
is valid [[temp.deduct]] and `x` otherwise; `OUTERMOST_ALLOC_TRAITS(x)`
|
| 223 |
+
is `allocator_traits<remove_reference_t<decltype(OUTERMOST(x))>>`.
|
|
|
|
|
|
|
| 224 |
|
| 225 |
[*Note 1*: `OUTERMOST(x)` and `OUTERMOST_ALLOC_TRAITS(x)` are recursive
|
| 226 |
operations. It is incumbent upon the definition of `outer_allocator()`
|
| 227 |
to ensure that the recursion terminates. It will terminate for all
|
| 228 |
instantiations of `scoped_allocator_adaptor`. — *end note*]
|
|
|
|
| 246 |
```
|
| 247 |
|
| 248 |
*Returns:* `static_cast<const OuterAlloc&>(*this)`.
|
| 249 |
|
| 250 |
``` cpp
|
| 251 |
+
[[nodiscard]] pointer allocate(size_type n);
|
| 252 |
```
|
| 253 |
|
| 254 |
*Returns:*
|
| 255 |
`allocator_traits<OuterAlloc>::allocate(outer_allocator(), n)`.
|
| 256 |
|
| 257 |
``` cpp
|
| 258 |
+
[[nodiscard]] pointer allocate(size_type n, const_void_pointer hint);
|
| 259 |
```
|
| 260 |
|
| 261 |
*Returns:*
|
| 262 |
`allocator_traits<OuterAlloc>::allocate(outer_allocator(), n, hint)`.
|
| 263 |
|
|
|
|
| 277 |
``` cpp
|
| 278 |
template<class T, class... Args>
|
| 279 |
void construct(T* p, Args&&... args);
|
| 280 |
```
|
| 281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
*Effects:* Equivalent to:
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
+
apply([p, this](auto&&... newargs) {
|
| 286 |
+
OUTERMOST_ALLOC_TRAITS(*this)::construct(
|
| 287 |
+
OUTERMOST(*this), p,
|
| 288 |
+
std::forward<decltype(newargs)>(newargs)...);
|
| 289 |
+
},
|
| 290 |
+
uses_allocator_construction_args<T>(inner_allocator(),
|
| 291 |
+
std::forward<Args>(args)...));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
```
|
| 293 |
|
| 294 |
``` cpp
|
| 295 |
template<class T>
|
| 296 |
void destroy(T* p);
|
|
|
|
| 306 |
*Returns:* A new `scoped_allocator_adaptor` object where each allocator
|
| 307 |
`A` in the adaptor is initialized from the result of calling
|
| 308 |
`allocator_traits<A>::select_on_container_copy_construction()` on the
|
| 309 |
corresponding allocator in `*this`.
|
| 310 |
|
| 311 |
+
### Operators <a id="scoped.adaptor.operators">[[scoped.adaptor.operators]]</a>
|
| 312 |
|
| 313 |
``` cpp
|
| 314 |
template<class OuterA1, class OuterA2, class... InnerAllocs>
|
| 315 |
bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a,
|
| 316 |
const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& b) noexcept;
|
|
|
|
| 326 |
|
| 327 |
``` cpp
|
| 328 |
a.outer_allocator() == b.outer_allocator() && a.inner_allocator() == b.inner_allocator()
|
| 329 |
```
|
| 330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|