- tmp/tmphq8s8znw/{from.md → to.md} +1182 -519
tmp/tmphq8s8znw/{from.md → to.md}
RENAMED
|
@@ -12,10 +12,11 @@ C++standard library. These utilities are summarized in Table
|
|
| 12 |
| Subclause | | Header |
|
| 13 |
| --------------------- | -------------------------------- | -------------------- |
|
| 14 |
| [[utility]] | Utility components | `<utility>` |
|
| 15 |
| [[pairs]] | Pairs | `<utility>` |
|
| 16 |
| [[tuple]] | Tuples | `<tuple>` |
|
|
|
|
| 17 |
| [[template.bitset]] | Fixed-size sequences of bits | `<bitset>` |
|
| 18 |
| | | `<memory>` |
|
| 19 |
| [[memory]] | Memory | `<cstdlib>` |
|
| 20 |
| | | `<cstring>` |
|
| 21 |
| [[smartptr]] | Smart pointers | `<memory>` |
|
|
@@ -53,63 +54,98 @@ namespace std {
|
|
| 53 |
|
| 54 |
// [utility.swap], swap:
|
| 55 |
template<class T> void swap(T& a, T& b) noexcept(see below);
|
| 56 |
template <class T, size_t N> void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
// [forward], forward/move:
|
| 59 |
-
template <class T>
|
| 60 |
-
|
| 61 |
-
template <class T>
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
|
| 64 |
-
const T&, T&&>
|
| 65 |
|
| 66 |
// [declval], declval:
|
| 67 |
template <class T>
|
| 68 |
-
|
| 69 |
|
| 70 |
// [pairs], pairs:
|
| 71 |
template <class T1, class T2> struct pair;
|
| 72 |
|
| 73 |
// [pairs.spec], pair specialized algorithms:
|
| 74 |
template <class T1, class T2>
|
| 75 |
-
bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 76 |
template <class T1, class T2>
|
| 77 |
-
bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
|
| 78 |
template <class T1, class T2>
|
| 79 |
-
bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 80 |
template <class T1, class T2>
|
| 81 |
-
bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
|
| 82 |
template <class T1, class T2>
|
| 83 |
-
bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 84 |
template <class T1, class T2>
|
| 85 |
-
bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 86 |
template <class T1, class T2>
|
| 87 |
void swap(pair<T1,T2>& x, pair<T1,T2>& y) noexcept(noexcept(x.swap(y)));
|
| 88 |
template <class T1, class T2>
|
| 89 |
-
see below make_pair(T1&&, T2&&);
|
| 90 |
|
| 91 |
// [pair.astuple], tuple-like access to pair:
|
| 92 |
template <class T> class tuple_size;
|
| 93 |
template <size_t I, class T> class tuple_element;
|
| 94 |
|
| 95 |
-
template <class T1, class T2> struct tuple_size<
|
| 96 |
-
template <class T1, class T2> struct tuple_element<0,
|
| 97 |
-
template <class T1, class T2> struct tuple_element<1,
|
| 98 |
|
| 99 |
template<size_t I, class T1, class T2>
|
| 100 |
-
|
|
|
|
| 101 |
template<size_t I, class T1, class T2>
|
| 102 |
-
|
|
|
|
| 103 |
template<size_t I, class T1, class T2>
|
| 104 |
-
const
|
| 105 |
-
get(const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
// [pair.piecewise], pair piecewise construction
|
| 108 |
struct piecewise_construct_t { };
|
| 109 |
-
constexpr piecewise_construct_t piecewise_construct
|
| 110 |
template <class... Types> class tuple; // defined in <tuple>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
}
|
| 112 |
```
|
| 113 |
|
| 114 |
### Operators <a id="operators">[[operators]]</a>
|
| 115 |
|
|
@@ -185,24 +221,38 @@ template<class T, size_t N>
|
|
| 185 |
*Requires:* `a[i]` shall be swappable with ([[swappable.requirements]])
|
| 186 |
`b[i]` for all `i` in the range \[`0`, `N`).
|
| 187 |
|
| 188 |
*Effects:* `swap_ranges(a, a + N, b)`
|
| 189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
### forward/move helpers <a id="forward">[[forward]]</a>
|
| 191 |
|
| 192 |
The library provides templated helper functions to simplify applying
|
| 193 |
move semantics to an lvalue and to simplify the implementation of
|
| 194 |
forwarding functions.
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
-
template <class T> T&& forward(
|
| 198 |
-
template <class T> T&& forward(
|
| 199 |
```
|
| 200 |
|
| 201 |
*Returns:* `static_cast<T&&>(t)`.
|
| 202 |
|
| 203 |
-
|
| 204 |
program is ill-formed.
|
| 205 |
|
| 206 |
``` cpp
|
| 207 |
template <class T, class A1, class A2>
|
| 208 |
shared_ptr<T> factory(A1&& a1, A2&& a2) {
|
|
@@ -225,14 +275,14 @@ forwarded to `A`’s constructor as an rvalue. In the second call to
|
|
| 225 |
`factory`, `A1` is deduced as `int&`, so `i` is forwarded to `A`’s
|
| 226 |
constructor as an lvalue. In both cases, `A2` is deduced as `double`, so
|
| 227 |
1.414 is forwarded to `A`’s constructor as an rvalue.
|
| 228 |
|
| 229 |
``` cpp
|
| 230 |
-
template <class T>
|
| 231 |
```
|
| 232 |
|
| 233 |
-
*Returns:* `static_cast<
|
| 234 |
|
| 235 |
``` cpp
|
| 236 |
template <class T, class A1>
|
| 237 |
shared_ptr<T> factory(A1&& a1) {
|
| 238 |
return shared_ptr<T>(new T(std::forward<A1>(a1)));
|
|
@@ -257,13 +307,13 @@ forwarded as a non-const lvalue. This binds to the constructor
|
|
| 257 |
`factory`, because of the call `std::move(a)`, `A1` is deduced as `A`,
|
| 258 |
so `a` is forwarded as an rvalue. This binds to the constructor
|
| 259 |
`A(A&&)`, which moves the value from `a`.
|
| 260 |
|
| 261 |
``` cpp
|
| 262 |
-
template <class T>
|
| 263 |
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
|
| 264 |
-
const T&, T&&>
|
| 265 |
```
|
| 266 |
|
| 267 |
*Returns:* `std::move(x)`
|
| 268 |
|
| 269 |
### Function template `declval` <a id="declval">[[declval]]</a>
|
|
@@ -272,11 +322,11 @@ The library provides the function template `declval` to simplify the
|
|
| 272 |
definition of expressions which occur as unevaluated operands (Clause
|
| 273 |
[[expr]]).
|
| 274 |
|
| 275 |
``` cpp
|
| 276 |
template <class T>
|
| 277 |
-
|
| 278 |
```
|
| 279 |
|
| 280 |
*Remarks:* If this function is odr-used ([[basic.def.odr]]), the
|
| 281 |
program is ill-formed.
|
| 282 |
|
|
@@ -317,14 +367,14 @@ namespace std {
|
|
| 317 |
T1 first;
|
| 318 |
T2 second;
|
| 319 |
pair(const pair&) = default;
|
| 320 |
pair(pair&&) = default;
|
| 321 |
constexpr pair();
|
| 322 |
-
pair(const T1& x, const T2& y);
|
| 323 |
-
template<class U, class V> pair(U&& x, V&& y);
|
| 324 |
-
template<class U, class V> pair(const pair<U, V>& p);
|
| 325 |
-
template<class U, class V> pair(pair<U, V>&& p);
|
| 326 |
template <class... Args1, class... Args2>
|
| 327 |
pair(piecewise_construct_t,
|
| 328 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 329 |
|
| 330 |
pair& operator=(const pair& p);
|
|
@@ -335,14 +385,19 @@ namespace std {
|
|
| 335 |
void swap(pair& p) noexcept(see below);
|
| 336 |
};
|
| 337 |
}
|
| 338 |
```
|
| 339 |
|
| 340 |
-
Constructors and member
|
| 341 |
unless one of the element-wise operations specified to be called for
|
| 342 |
that operation throws an exception.
|
| 343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
``` cpp
|
| 345 |
constexpr pair();
|
| 346 |
```
|
| 347 |
|
| 348 |
*Requires:* `is_default_constructible<first_type>::value` is `true` and
|
|
@@ -350,21 +405,21 @@ constexpr pair();
|
|
| 350 |
`ible<second_type>::value` is `true`.
|
| 351 |
|
| 352 |
*Effects:* Value-initializes `first` and `second`.
|
| 353 |
|
| 354 |
``` cpp
|
| 355 |
-
pair(const T1& x, const T2& y);
|
| 356 |
```
|
| 357 |
|
| 358 |
*Requires:* `is_copy_constructible<first_type>::value` is `true` and
|
| 359 |
`is_copy_constructible<second_type>::value` is `true`.
|
| 360 |
|
| 361 |
*Effects:* The constructor initializes `first` with `x` and `second`
|
| 362 |
with `y`.
|
| 363 |
|
| 364 |
``` cpp
|
| 365 |
-
template<class U, class V> pair(U&& x, V&& y);
|
| 366 |
```
|
| 367 |
|
| 368 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 369 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 370 |
|
|
@@ -374,11 +429,11 @@ and `second` with `std::forward<V>(y)`.
|
|
| 374 |
*Remarks:* If `U` is not implicitly convertible to `first_type` or `V`
|
| 375 |
is not implicitly convertible to `second_type` this constructor shall
|
| 376 |
not participate in overload resolution.
|
| 377 |
|
| 378 |
``` cpp
|
| 379 |
-
template<class U, class V> pair(const pair<U, V>& p);
|
| 380 |
```
|
| 381 |
|
| 382 |
*Requires:* `is_constructible<first_type, const U&>::value` is `true`
|
| 383 |
and `is_constructible<second_type, const V&>::value` is `true`.
|
| 384 |
|
|
@@ -388,11 +443,11 @@ argument.
|
|
| 388 |
This constructor shall not participate in overload resolution unless
|
| 389 |
`const U&` is implicitly convertible to `first_type` and `const V&` is
|
| 390 |
implicitly convertible to `second_type`.
|
| 391 |
|
| 392 |
``` cpp
|
| 393 |
-
template<class U, class V> pair(pair<U, V>&& p);
|
| 394 |
```
|
| 395 |
|
| 396 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 397 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 398 |
|
|
@@ -408,13 +463,12 @@ convertible to `second_type`.
|
|
| 408 |
template<class... Args1, class... Args2>
|
| 409 |
pair(piecewise_construct_t,
|
| 410 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 411 |
```
|
| 412 |
|
| 413 |
-
*Requires:*
|
| 414 |
-
`is_constructible<
|
| 415 |
-
`is_constructible<second_type, Args2&&...>::value` is `true`.
|
| 416 |
|
| 417 |
*Effects:* The constructor initializes `first` with arguments of types
|
| 418 |
`Args1...` obtained by forwarding the elements of `first_args` and
|
| 419 |
initializes `second` with arguments of types `Args2...` obtained by
|
| 420 |
forwarding the elements of `second_args`. (Here, forwarding an element
|
|
@@ -436,12 +490,12 @@ pair& operator=(const pair& p);
|
|
| 436 |
|
| 437 |
``` cpp
|
| 438 |
template<class U, class V> pair& operator=(const pair<U, V>& p);
|
| 439 |
```
|
| 440 |
|
| 441 |
-
*Requires:* is_assignable
|
| 442 |
-
is_assignable
|
| 443 |
|
| 444 |
*Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
|
| 445 |
|
| 446 |
*Returns:* `*this`.
|
| 447 |
|
|
@@ -497,47 +551,47 @@ swappable with `p.second`.
|
|
| 497 |
|
| 498 |
### Specialized algorithms <a id="pairs.spec">[[pairs.spec]]</a>
|
| 499 |
|
| 500 |
``` cpp
|
| 501 |
template <class T1, class T2>
|
| 502 |
-
bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 503 |
```
|
| 504 |
|
| 505 |
*Returns:* `x.first == y.first && x.second == y.second`.
|
| 506 |
|
| 507 |
``` cpp
|
| 508 |
template <class T1, class T2>
|
| 509 |
-
bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 510 |
```
|
| 511 |
|
| 512 |
*Returns:*
|
| 513 |
`x.first < y.first || (!(y.first < x.first) && x.second < y.second)`.
|
| 514 |
|
| 515 |
``` cpp
|
| 516 |
template <class T1, class T2>
|
| 517 |
-
bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 518 |
```
|
| 519 |
|
| 520 |
*Returns:* `!(x == y)`
|
| 521 |
|
| 522 |
``` cpp
|
| 523 |
template <class T1, class T2>
|
| 524 |
-
bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 525 |
```
|
| 526 |
|
| 527 |
*Returns:* `y < x`
|
| 528 |
|
| 529 |
``` cpp
|
| 530 |
template <class T1, class T2>
|
| 531 |
-
bool operator>=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 532 |
```
|
| 533 |
|
| 534 |
*Returns:* `!(x < y)`
|
| 535 |
|
| 536 |
``` cpp
|
| 537 |
template <class T1, class T2>
|
| 538 |
-
bool operator<=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 539 |
```
|
| 540 |
|
| 541 |
*Returns:* `!(y < x)`
|
| 542 |
|
| 543 |
``` cpp
|
|
@@ -547,17 +601,17 @@ template<class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y)
|
|
| 547 |
|
| 548 |
*Effects:* `x.swap(y)`
|
| 549 |
|
| 550 |
``` cpp
|
| 551 |
template <class T1, class T2>
|
| 552 |
-
pair<V1, V2> make_pair(T1&& x, T2&& y);
|
| 553 |
```
|
| 554 |
|
| 555 |
*Returns:* `pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))`;
|
| 556 |
|
| 557 |
-
where `V1` and `V2` are determined as follows: Let `Ui` be
|
| 558 |
-
|
| 559 |
`reference_wrapper<X>`, otherwise `Vi` is `Ui`.
|
| 560 |
|
| 561 |
In place of:
|
| 562 |
|
| 563 |
``` cpp
|
|
@@ -571,17 +625,15 @@ return make_pair(5, 3.1415926); // types are deduced
|
|
| 571 |
```
|
| 572 |
|
| 573 |
### Tuple-like access to pair <a id="pair.astuple">[[pair.astuple]]</a>
|
| 574 |
|
| 575 |
``` cpp
|
| 576 |
-
|
|
|
|
|
|
|
| 577 |
```
|
| 578 |
|
| 579 |
-
*Returns:* Integral constant expression.
|
| 580 |
-
|
| 581 |
-
*Value:* 2.
|
| 582 |
-
|
| 583 |
``` cpp
|
| 584 |
tuple_element<0, pair<T1, T2> >::type
|
| 585 |
```
|
| 586 |
|
| 587 |
*Value:* the type `T1`.
|
|
@@ -592,32 +644,79 @@ tuple_element<1, pair<T1, T2> >::type
|
|
| 592 |
|
| 593 |
*Value:* the type T2.
|
| 594 |
|
| 595 |
``` cpp
|
| 596 |
template<size_t I, class T1, class T2>
|
| 597 |
-
|
|
|
|
| 598 |
template<size_t I, class T1, class T2>
|
| 599 |
-
const
|
|
|
|
| 600 |
```
|
| 601 |
|
| 602 |
*Returns:* If `I == 0` returns `p.first`; if `I == 1` returns
|
| 603 |
`p.second`; otherwise the program is ill-formed.
|
| 604 |
|
| 605 |
``` cpp
|
| 606 |
template<size_t I, class T1, class T2>
|
| 607 |
-
|
|
|
|
| 608 |
```
|
| 609 |
|
| 610 |
*Returns:* If `I == 0` returns `std::forward<T1&&>(p.first)`; if
|
| 611 |
`I == 1` returns `std::forward<T2&&>(p.second)`; otherwise the program
|
| 612 |
is ill-formed.
|
| 613 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
### Piecewise construction <a id="pair.piecewise">[[pair.piecewise]]</a>
|
| 615 |
|
| 616 |
``` cpp
|
| 617 |
struct piecewise_construct_t { };
|
| 618 |
-
constexpr piecewise_construct_t piecewise_construct
|
| 619 |
```
|
| 620 |
|
| 621 |
The `struct` `piecewise_construct_t` is an empty structure type used as
|
| 622 |
a unique type to disambiguate constructor and function overloading.
|
| 623 |
Specifically, `pair` has a constructor with `piecewise_construct_t` as
|
|
@@ -644,19 +743,19 @@ namespace std {
|
|
| 644 |
|
| 645 |
// [tuple.creation], tuple creation functions:
|
| 646 |
const unspecified ignore;
|
| 647 |
|
| 648 |
template <class... Types>
|
| 649 |
-
tuple<VTypes...> make_tuple(Types&&...);
|
| 650 |
template <class... Types>
|
| 651 |
-
tuple<Types...> forward_as_tuple(Types&&...) noexcept;
|
| 652 |
|
| 653 |
template<class... Types>
|
| 654 |
-
tuple<Types&...> tie(Types&...) noexcept;
|
| 655 |
|
| 656 |
template <class... Tuples>
|
| 657 |
-
tuple<Ctypes...> tuple_cat(Tuples&&...);
|
| 658 |
|
| 659 |
// [tuple.helper], tuple helper classes:
|
| 660 |
template <class T> class tuple_size; // undefined
|
| 661 |
template <class T> class tuple_size<const T>;
|
| 662 |
template <class T> class tuple_size<volatile T>;
|
|
@@ -669,31 +768,43 @@ namespace std {
|
|
| 669 |
template <size_t I, class T> class tuple_element<I, volatile T>;
|
| 670 |
template <size_t I, class T> class tuple_element<I, const volatile T>;
|
| 671 |
|
| 672 |
template <size_t I, class... Types> class tuple_element<I, tuple<Types...> >;
|
| 673 |
|
|
|
|
|
|
|
|
|
|
| 674 |
// [tuple.elem], element access:
|
| 675 |
template <size_t I, class... Types>
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 681 |
|
| 682 |
// [tuple.rel], relational operators:
|
| 683 |
template<class... TTypes, class... UTypes>
|
| 684 |
-
bool operator==(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 685 |
template<class... TTypes, class... UTypes>
|
| 686 |
-
bool operator<(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 687 |
template<class... TTypes, class... UTypes>
|
| 688 |
-
bool operator!=(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 689 |
template<class... TTypes, class... UTypes>
|
| 690 |
-
bool operator>(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 691 |
template<class... TTypes, class... UTypes>
|
| 692 |
-
bool operator<=(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 693 |
template<class... TTypes, class... UTypes>
|
| 694 |
-
bool operator>=(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 695 |
|
| 696 |
// [tuple.traits], allocator-related traits
|
| 697 |
template <class... Types, class Alloc>
|
| 698 |
struct uses_allocator<tuple<Types...>, Alloc>;
|
| 699 |
|
|
@@ -711,26 +822,26 @@ namespace std {
|
|
| 711 |
class tuple {
|
| 712 |
public:
|
| 713 |
|
| 714 |
// [tuple.cnstr], tuple construction
|
| 715 |
constexpr tuple();
|
| 716 |
-
explicit tuple(const Types&...);
|
| 717 |
template <class... UTypes>
|
| 718 |
-
explicit tuple(UTypes&&...);
|
| 719 |
|
| 720 |
tuple(const tuple&) = default;
|
| 721 |
tuple(tuple&&) = default;
|
| 722 |
|
| 723 |
template <class... UTypes>
|
| 724 |
-
tuple(const tuple<UTypes...>&);
|
| 725 |
template <class... UTypes>
|
| 726 |
-
tuple(tuple<UTypes...>&&);
|
| 727 |
|
| 728 |
template <class U1, class U2>
|
| 729 |
-
tuple(const pair<U1, U2>&); //
|
| 730 |
template <class U1, class U2>
|
| 731 |
-
tuple(pair<U1, U2>&&); //
|
| 732 |
|
| 733 |
// allocator-extended constructors
|
| 734 |
template <class Alloc>
|
| 735 |
tuple(allocator_arg_t, const Alloc& a);
|
| 736 |
template <class Alloc>
|
|
@@ -758,13 +869,13 @@ namespace std {
|
|
| 758 |
tuple& operator=(const tuple<UTypes...>&);
|
| 759 |
template <class... UTypes>
|
| 760 |
tuple& operator=(tuple<UTypes...>&&);
|
| 761 |
|
| 762 |
template <class U1, class U2>
|
| 763 |
-
tuple& operator=(const pair<U1, U2>&); //
|
| 764 |
template <class U1, class U2>
|
| 765 |
-
tuple& operator=(pair<U1, U2>&&); //
|
| 766 |
|
| 767 |
// [tuple.swap], tuple swap
|
| 768 |
void swap(tuple&) noexcept(see below);
|
| 769 |
};
|
| 770 |
}
|
|
@@ -773,10 +884,16 @@ namespace std {
|
|
| 773 |
#### Construction <a id="tuple.cnstr">[[tuple.cnstr]]</a>
|
| 774 |
|
| 775 |
For each `tuple` constructor, an exception is thrown only if the
|
| 776 |
construction of one of the types in `Types` throws an exception.
|
| 777 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 778 |
In the constructor descriptions that follow, let i be in the range
|
| 779 |
\[`0`, `sizeof...(Types)`) in order, Tᵢ be the iᵗʰ type in `Types`, and
|
| 780 |
Uᵢ be the iᵗʰ type in a template parameter pack named `UTypes`, where
|
| 781 |
indexing is zero-based.
|
| 782 |
|
|
@@ -787,21 +904,21 @@ constexpr tuple();
|
|
| 787 |
*Requires:* `is_default_constructible<`Tᵢ`>::value` is true for all i.
|
| 788 |
|
| 789 |
*Effects:* Value initializes each element.
|
| 790 |
|
| 791 |
``` cpp
|
| 792 |
-
explicit tuple(const Types&...);
|
| 793 |
```
|
| 794 |
|
| 795 |
*Requires:* `is_copy_constructible<`Tᵢ`>::value` is true for all i.
|
| 796 |
|
| 797 |
*Effects:* Initializes each element with the value of the corresponding
|
| 798 |
parameter.
|
| 799 |
|
| 800 |
``` cpp
|
| 801 |
template <class... UTypes>
|
| 802 |
-
explicit tuple(UTypes&&... u);
|
| 803 |
```
|
| 804 |
|
| 805 |
*Requires:* `sizeof...(Types)` `==` `sizeof...(UTypes)`.
|
| 806 |
`is_constructible<`Tᵢ`, `Uᵢ`&&>::value` is `true` for all i.
|
| 807 |
|
|
@@ -829,11 +946,11 @@ tuple(tuple&& u) = default;
|
|
| 829 |
|
| 830 |
*Effects:* For all i, initializes the iᵗʰ element of `*this` with
|
| 831 |
`std::forward<`Tᵢ`>(get<`i`>(u))`.
|
| 832 |
|
| 833 |
``` cpp
|
| 834 |
-
template <class... UTypes> tuple(const tuple<UTypes...>& u);
|
| 835 |
```
|
| 836 |
|
| 837 |
*Requires:* `sizeof...(Types)` `==` `sizeof...(UTypes)`.
|
| 838 |
`is_constructible<`Tᵢ`, const `Uᵢ`&>::value` is `true` for all i.
|
| 839 |
|
|
@@ -842,11 +959,11 @@ element of `u`.
|
|
| 842 |
|
| 843 |
This constructor shall not participate in overload resolution unless
|
| 844 |
`const `Uᵢ`&` is implicitly convertible to Tᵢ for all i.
|
| 845 |
|
| 846 |
``` cpp
|
| 847 |
-
template <class... UTypes> tuple(tuple<UTypes...>&& u);
|
| 848 |
```
|
| 849 |
|
| 850 |
*Requires:* `sizeof...(Types)` `==` `sizeof...(UTypes)`.
|
| 851 |
`is_constructible<`Tᵢ`, `Uᵢ`&&>::value` is `true` for all i.
|
| 852 |
|
|
@@ -856,11 +973,11 @@ template <class... UTypes> tuple(tuple<UTypes...>&& u);
|
|
| 856 |
This constructor shall not participate in overload resolution unless
|
| 857 |
each type in `UTypes` is implicitly convertible to its corresponding
|
| 858 |
type in `Types`.
|
| 859 |
|
| 860 |
``` cpp
|
| 861 |
-
template <class U1, class U2> tuple(const pair<U1, U2>& u);
|
| 862 |
```
|
| 863 |
|
| 864 |
*Requires:* `sizeof...(Types) == 2`.
|
| 865 |
`is_constructible<`T₀`, const U1&>::value` is `true` for the first type
|
| 866 |
T₀ in `Types` and `is_constructible<`T₁`, const U2&>::value` is `true`
|
|
@@ -872,11 +989,11 @@ element with `u.second`.
|
|
| 872 |
This constructor shall not participate in overload resolution unless
|
| 873 |
`const U1&` is implicitly convertible to T₀ and `const U2&` is
|
| 874 |
implicitly convertible to T₁.
|
| 875 |
|
| 876 |
``` cpp
|
| 877 |
-
template <class U1, class U2> tuple(pair<U1, U2>&& u);
|
| 878 |
```
|
| 879 |
|
| 880 |
*Requires:* `sizeof...(Types) == 2`.
|
| 881 |
`is_constructible<`T₀`, U1&&>::value` is `true` for the first type T₀ in
|
| 882 |
`Types` and `is_constructible<`T₁`, U2&&>::value` is `true` for the
|
|
@@ -1025,11 +1142,11 @@ The expression inside `noexcept` is equivalent to the logical
|
|
| 1025 |
|
| 1026 |
``` cpp
|
| 1027 |
noexcept(swap(declval<Tᵢ&>>(), declval<Tᵢ&>()))
|
| 1028 |
```
|
| 1029 |
|
| 1030 |
-
where T
|
| 1031 |
|
| 1032 |
*Requires:* Each element in `*this` shall be swappable
|
| 1033 |
with ([[swappable.requirements]]) the corresponding element in `rhs`.
|
| 1034 |
|
| 1035 |
*Effects:* Calls `swap` for each element in `*this` and its
|
|
@@ -1046,14 +1163,14 @@ parameter pack named `TTypes`; let j be in the range \[`0`,
|
|
| 1046 |
`sizeof...(UTypes)`) in order and Uⱼ be the jᵗʰ type in a template
|
| 1047 |
parameter pack named `UTypes`, where indexing is zero-based.
|
| 1048 |
|
| 1049 |
``` cpp
|
| 1050 |
template<class... Types>
|
| 1051 |
-
tuple<VTypes...> make_tuple(Types&&... t);
|
| 1052 |
```
|
| 1053 |
|
| 1054 |
-
Let Uᵢ be `
|
| 1055 |
`VTypes` is `X&` if Uᵢ equals `reference_wrapper<X>`, otherwise Vᵢ is
|
| 1056 |
Uᵢ.
|
| 1057 |
|
| 1058 |
*Returns:* `tuple<VTypes...>(std::forward<Types>(t)...)`.
|
| 1059 |
|
|
@@ -1068,11 +1185,11 @@ creates a tuple of type
|
|
| 1068 |
tuple<int, int&, const float&>
|
| 1069 |
```
|
| 1070 |
|
| 1071 |
``` cpp
|
| 1072 |
template<class... Types>
|
| 1073 |
-
tuple<Types&&...> forward_as_tuple(Types&&... t) noexcept;
|
| 1074 |
```
|
| 1075 |
|
| 1076 |
*Effects:* Constructs a tuple of references to the arguments in `t`
|
| 1077 |
suitable for forwarding as arguments to a function. Because the result
|
| 1078 |
may contain references to temporary variables, a program shall ensure
|
|
@@ -1082,15 +1199,16 @@ named variable).
|
|
| 1082 |
|
| 1083 |
*Returns:* `tuple<Types&&...>(std::forward<Types>(t)...)`
|
| 1084 |
|
| 1085 |
``` cpp
|
| 1086 |
template<class... Types>
|
| 1087 |
-
tuple<Types&...> tie(Types&... t) noexcept;
|
| 1088 |
```
|
| 1089 |
|
| 1090 |
-
*Returns:* `tuple<Types&>(t...)`. When an argument in `t` is
|
| 1091 |
-
assigning any value to the corresponding tuple element has no
|
|
|
|
| 1092 |
|
| 1093 |
`tie` functions allow one to create tuples that unpack tuples into
|
| 1094 |
variables. `ignore` can be used for elements that are not needed:
|
| 1095 |
|
| 1096 |
``` cpp
|
|
@@ -1099,16 +1217,16 @@ tie(i, ignore, s) = make_tuple(42, 3.14, "C++");
|
|
| 1099 |
// i == 42, s == "C++"
|
| 1100 |
```
|
| 1101 |
|
| 1102 |
``` cpp
|
| 1103 |
template <class... Tuples>
|
| 1104 |
-
tuple<CTypes...> tuple_cat(Tuples&&... tpls);
|
| 1105 |
```
|
| 1106 |
|
| 1107 |
In the following paragraphs, let Tᵢ be the iᵗʰ type in `Tuples`, Uᵢ be
|
| 1108 |
-
`
|
| 1109 |
-
|
| 1110 |
|
| 1111 |
*Requires:* For all i, Uᵢ shall be the type cvᵢ `tuple<`Argsᵢ...`>`,
|
| 1112 |
where cvᵢ is the (possibly empty) iᵗʰ cv-qualifier-seq and Argsᵢ is the
|
| 1113 |
parameter pack representing the element types in Uᵢ. Let {Aᵢₖ} be the
|
| 1114 |
kᵢᵗʰ type in Argsᵢ. For all Aᵢₖ the following requirements shall be
|
|
@@ -1131,10 +1249,18 @@ eᵢ in order.
|
|
| 1131 |
pack `Tuples` that support the `tuple`-like protocol, such as `pair` and
|
| 1132 |
`array`.
|
| 1133 |
|
| 1134 |
#### Tuple helper classes <a id="tuple.helper">[[tuple.helper]]</a>
|
| 1135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1136 |
``` cpp
|
| 1137 |
template <class... Types>
|
| 1138 |
class tuple_size<tuple<Types...> >
|
| 1139 |
: public integral_constant<size_t, sizeof...(Types)> { };
|
| 1140 |
```
|
|
@@ -1162,11 +1288,11 @@ template <class T> class tuple_size<const volatile T>;
|
|
| 1162 |
Let *TS* denote `tuple_size<T>` of the cv-unqualified type `T`. Then
|
| 1163 |
each of the three templates shall meet the `UnaryTypeTrait`
|
| 1164 |
requirements ([[meta.rqmts]]) with a `BaseCharacteristic` of
|
| 1165 |
|
| 1166 |
``` cpp
|
| 1167 |
-
integral_constant<
|
| 1168 |
```
|
| 1169 |
|
| 1170 |
``` cpp
|
| 1171 |
template <size_t I, class T> class tuple_element<I, const T>;
|
| 1172 |
template <size_t I, class T> class tuple_element<I, volatile T>;
|
|
@@ -1176,31 +1302,30 @@ template <size_t I, class T> class tuple_element<I, const volatile T>;
|
|
| 1176 |
Let *TE* denote `tuple_element<I, T>` of the cv-unqualified type `T`.
|
| 1177 |
Then each of the three templates shall meet the `TransformationTrait`
|
| 1178 |
requirements ([[meta.rqmts]]) with a member typedef `type` that names
|
| 1179 |
the following type:
|
| 1180 |
|
| 1181 |
-
- for the first specialization, `
|
| 1182 |
-
- for the second specialization, `
|
| 1183 |
-
|
| 1184 |
-
- for the third specialization, `add_cv<`*`TE`*`::type>::type`.
|
| 1185 |
|
| 1186 |
#### Element access <a id="tuple.elem">[[tuple.elem]]</a>
|
| 1187 |
|
| 1188 |
``` cpp
|
| 1189 |
template <size_t I, class... Types>
|
| 1190 |
-
|
| 1191 |
```
|
| 1192 |
|
| 1193 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 1194 |
out of bounds.
|
| 1195 |
|
| 1196 |
*Returns:* A reference to the `I`th element of `t`, where indexing is
|
| 1197 |
zero-based.
|
| 1198 |
|
| 1199 |
``` cpp
|
| 1200 |
-
template <size_t I, class...
|
| 1201 |
-
|
| 1202 |
```
|
| 1203 |
|
| 1204 |
*Effects:* Equivalent to
|
| 1205 |
`return std::forward<typename tuple_element<I, tuple<Types...> >`
|
| 1206 |
`::type&&>(get<I>(t));`
|
|
@@ -1209,11 +1334,11 @@ template <size_t I, class... types>
|
|
| 1209 |
is `X&`, not `X&&`. However, if the element type is a non-reference type
|
| 1210 |
`T`, the return type is `T&&`.
|
| 1211 |
|
| 1212 |
``` cpp
|
| 1213 |
template <size_t I, class... Types>
|
| 1214 |
-
|
| 1215 |
```
|
| 1216 |
|
| 1217 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 1218 |
out of bounds.
|
| 1219 |
|
|
@@ -1224,38 +1349,61 @@ Constness is shallow. If a `T` in `Types` is some reference type `X&`,
|
|
| 1224 |
the return type is `X&`, not `const X&`. However, if the element type is
|
| 1225 |
non-reference type `T`, the return type is `const T&`. This is
|
| 1226 |
consistent with how constness is defined to work for member variables of
|
| 1227 |
reference type.
|
| 1228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1229 |
The reason `get` is a nonmember function is that if this functionality
|
| 1230 |
had been provided as a member function, code where the type depended on
|
| 1231 |
a template parameter would have required using the `template` keyword.
|
| 1232 |
|
| 1233 |
#### Relational operators <a id="tuple.rel">[[tuple.rel]]</a>
|
| 1234 |
|
| 1235 |
``` cpp
|
| 1236 |
template<class... TTypes, class... UTypes>
|
| 1237 |
-
bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1238 |
```
|
| 1239 |
|
| 1240 |
-
*Requires:* For all `i`, where `0 <= i` and `i < sizeof...(
|
| 1241 |
`get<i>(t) == get<i>(u)` is a valid expression returning a type that is
|
| 1242 |
convertible to `bool`. `sizeof...(TTypes)` `==` `sizeof...(UTypes)`.
|
| 1243 |
|
| 1244 |
-
*Returns:* `true`
|
| 1245 |
-
zero-length tuples `e` and `f`, `e == f` returns
|
|
|
|
| 1246 |
|
| 1247 |
*Effects:* The elementary comparisons are performed in order from the
|
| 1248 |
zeroth index upwards. No comparisons or element accesses are performed
|
| 1249 |
after the first equality comparison that evaluates to `false`.
|
| 1250 |
|
| 1251 |
``` cpp
|
| 1252 |
template<class... TTypes, class... UTypes>
|
| 1253 |
-
bool operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1254 |
```
|
| 1255 |
|
| 1256 |
-
*Requires:* For all `i`, where `0 <= i` and `i < sizeof...(
|
| 1257 |
`get<i>(t) < get<i>(u)` and `get<i>(u) < get<i>(t)` are valid
|
| 1258 |
expressions returning types that are convertible to `bool`.
|
| 1259 |
`sizeof...(TTypes)` `==` `sizeof...(UTypes)`.
|
| 1260 |
|
| 1261 |
*Returns:* The result of a lexicographical comparison between `t` and
|
|
@@ -1265,32 +1413,32 @@ where `r`ₜₐᵢₗ for some tuple `r` is a tuple containing all but the first
|
|
| 1265 |
element of `r`. For any two zero-length tuples `e` and `f`, `e < f`
|
| 1266 |
returns `false`.
|
| 1267 |
|
| 1268 |
``` cpp
|
| 1269 |
template<class... TTypes, class... UTypes>
|
| 1270 |
-
bool operator!=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1271 |
```
|
| 1272 |
|
| 1273 |
*Returns:* `!(t == u)`.
|
| 1274 |
|
| 1275 |
``` cpp
|
| 1276 |
template<class... TTypes, class... UTypes>
|
| 1277 |
-
bool operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1278 |
```
|
| 1279 |
|
| 1280 |
*Returns:* `u < t`.
|
| 1281 |
|
| 1282 |
``` cpp
|
| 1283 |
template<class... TTypes, class... UTypes>
|
| 1284 |
-
bool operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1285 |
```
|
| 1286 |
|
| 1287 |
*Returns:* `!(u < t)`
|
| 1288 |
|
| 1289 |
``` cpp
|
| 1290 |
template<class... TTypes, class... UTypes>
|
| 1291 |
-
bool operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1292 |
```
|
| 1293 |
|
| 1294 |
*Returns:* `!(t < u)`
|
| 1295 |
|
| 1296 |
The above definitions for comparison operators do not require `tₜₐᵢₗ`
|
|
@@ -1326,10 +1474,62 @@ The expression inside `noexcept` is equivalent to:
|
|
| 1326 |
noexcept(x.swap(y))
|
| 1327 |
```
|
| 1328 |
|
| 1329 |
*Effects:* `x.swap(y)`
|
| 1330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1331 |
## Class template `bitset` <a id="template.bitset">[[template.bitset]]</a>
|
| 1332 |
|
| 1333 |
\synopsis{Header \texttt{\<bitset\>} synopsis}
|
| 1334 |
|
| 1335 |
``` cpp
|
|
@@ -1415,11 +1615,11 @@ namespace std {
|
|
| 1415 |
class traits = char_traits<charT>,
|
| 1416 |
class Allocator = allocator<charT> >
|
| 1417 |
basic_string<charT, traits, Allocator>
|
| 1418 |
to_string(charT zero = charT('0'), charT one = charT('1')) const;
|
| 1419 |
size_t count() const noexcept;
|
| 1420 |
-
constexpr size_t size() noexcept;
|
| 1421 |
bool operator==(const bitset<N>& rhs) const noexcept;
|
| 1422 |
bool operator!=(const bitset<N>& rhs) const noexcept;
|
| 1423 |
bool test(size_t pos) const;
|
| 1424 |
bool all() const noexcept;
|
| 1425 |
bool any() const noexcept;
|
|
@@ -1500,13 +1700,13 @@ position `pos` is other than `zero` or `one`. The function uses
|
|
| 1500 |
Otherwise, the function constructs an object of class `bitset<N>`,
|
| 1501 |
initializing the first `M` bit positions to values determined from the
|
| 1502 |
corresponding characters in the string `str`. `M` is the smaller of `N`
|
| 1503 |
and `rlen`.
|
| 1504 |
|
| 1505 |
-
An element of the constructed
|
| 1506 |
-
character in `str`, beginning at position `pos`, is `
|
| 1507 |
-
|
| 1508 |
corresponds to bit position zero. Subsequent decreasing character
|
| 1509 |
positions correspond to increasing bit positions.
|
| 1510 |
|
| 1511 |
If `M < N`, remaining bit positions are initialized to zero.
|
| 1512 |
|
|
@@ -1699,11 +1899,11 @@ size_t count() const noexcept;
|
|
| 1699 |
```
|
| 1700 |
|
| 1701 |
*Returns:* A count of the number of bits set in `*this`.
|
| 1702 |
|
| 1703 |
``` cpp
|
| 1704 |
-
constexpr size_t size() noexcept;
|
| 1705 |
```
|
| 1706 |
|
| 1707 |
*Returns:* `N`.
|
| 1708 |
|
| 1709 |
``` cpp
|
|
@@ -1760,11 +1960,11 @@ bitset<N> operator>>(size_t pos) const noexcept;
|
|
| 1760 |
```
|
| 1761 |
|
| 1762 |
*Returns:* `bitset<N>(*this) >>= pos`.
|
| 1763 |
|
| 1764 |
``` cpp
|
| 1765 |
-
constexpr bool operator[](size_t pos);
|
| 1766 |
```
|
| 1767 |
|
| 1768 |
*Requires:* `pos` shall be valid.
|
| 1769 |
|
| 1770 |
*Returns:* `true` if the bit at position `pos` in `*this` has the value
|
|
@@ -1793,12 +1993,12 @@ entire underlying bitset.
|
|
| 1793 |
|
| 1794 |
``` cpp
|
| 1795 |
template <size_t N> struct hash<bitset<N> >;
|
| 1796 |
```
|
| 1797 |
|
| 1798 |
-
|
| 1799 |
-
|
| 1800 |
|
| 1801 |
### `bitset` operators <a id="bitset.operators">[[bitset.operators]]</a>
|
| 1802 |
|
| 1803 |
``` cpp
|
| 1804 |
bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
|
|
@@ -1863,20 +2063,20 @@ os << x.template to_string<charT,traits,allocator<charT> >(
|
|
| 1863 |
|
| 1864 |
### In general <a id="memory.general">[[memory.general]]</a>
|
| 1865 |
|
| 1866 |
This subclause describes the contents of the header `<memory>` (
|
| 1867 |
[[memory.syn]]) and some of the contents of the C headers `<cstdlib>`
|
| 1868 |
-
and `cstring>` ([[c.malloc]]).
|
| 1869 |
|
| 1870 |
### Header `<memory>` synopsis <a id="memory.syn">[[memory.syn]]</a>
|
| 1871 |
|
| 1872 |
The header `<memory>` defines several types and function templates that
|
| 1873 |
describe properties of pointers and pointer-like types, manage memory
|
| 1874 |
for containers and other template types, and construct multiple objects
|
| 1875 |
in uninitialized memory buffers ([[pointer.traits]]–
|
| 1876 |
[[specialized.algorithms]]). The header also defines the templates
|
| 1877 |
-
`unique_ptr`, `shared_ptr`, `weak_ptr`, and various
|
| 1878 |
that operate on objects of these types ([[smartptr]]).
|
| 1879 |
|
| 1880 |
``` cpp
|
| 1881 |
namespace std {
|
| 1882 |
// [pointer.traits], pointer traits
|
|
@@ -1895,11 +2095,11 @@ namespace std {
|
|
| 1895 |
void* align(std::size_t alignment, std::size_t size,
|
| 1896 |
void*& ptr, std::size_t& space);
|
| 1897 |
|
| 1898 |
// [allocator.tag], allocator argument tag
|
| 1899 |
struct allocator_arg_t { };
|
| 1900 |
-
constexpr allocator_arg_t allocator_arg
|
| 1901 |
|
| 1902 |
// [allocator.uses], uses_allocator
|
| 1903 |
template <class T, class Alloc> struct uses_allocator;
|
| 1904 |
|
| 1905 |
// [allocator.traits], allocator traits
|
|
@@ -1940,10 +2140,16 @@ namespace std {
|
|
| 1940 |
template <class T> struct default_delete;
|
| 1941 |
template <class T> struct default_delete<T[]>;
|
| 1942 |
template <class T, class D = default_delete<T>> class unique_ptr;
|
| 1943 |
template <class T, class D> class unique_ptr<T[], D>;
|
| 1944 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1945 |
template <class T1, class D1, class T2, class D2>
|
| 1946 |
bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 1947 |
template <class T1, class D1, class T2, class D2>
|
| 1948 |
bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 1949 |
template <class T1, class D1, class T2, class D2>
|
|
@@ -1984,10 +2190,15 @@ namespace std {
|
|
| 1984 |
class bad_weak_ptr;
|
| 1985 |
|
| 1986 |
// [util.smartptr.shared], class template shared_ptr:
|
| 1987 |
template<class T> class shared_ptr;
|
| 1988 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1989 |
// [util.smartptr.shared.cmp], shared_ptr comparisons:
|
| 1990 |
template<class T, class U>
|
| 1991 |
bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
|
| 1992 |
template<class T, class U>
|
| 1993 |
bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
|
|
@@ -2161,18 +2372,18 @@ arguments; otherwise, the instantiation of `rebind` is ill-formed.
|
|
| 2161 |
``` cpp
|
| 2162 |
static pointer pointer_traits::pointer_to(see below r);
|
| 2163 |
static pointer pointer_traits<T*>::pointer_to(see below r) noexcept;
|
| 2164 |
```
|
| 2165 |
|
| 2166 |
-
|
| 2167 |
unspecified; otherwise, it is `element_type&`.
|
| 2168 |
|
| 2169 |
-
*Returns:* The first member function returns a
|
| 2170 |
-
|
| 2171 |
-
this function is ill-formed if `Ptr` does not have a
|
| 2172 |
-
`pointer_to` static member function. The second member function
|
| 2173 |
-
`std::addressof(r)`.
|
| 2174 |
|
| 2175 |
### Pointer safety <a id="util.dynamic.safety">[[util.dynamic.safety]]</a>
|
| 2176 |
|
| 2177 |
A complete object is *declared reachable* while the number of calls to
|
| 2178 |
`declare_reachable` with an argument referencing the object exceeds the
|
|
@@ -2223,15 +2434,15 @@ object must be live until the corresponding `undeclare_no_pointers()`
|
|
| 2223 |
call. In a garbage-collecting implementation, the fact that a region in
|
| 2224 |
an object is registered with `declare_no_pointers()` should not prevent
|
| 2225 |
the object from being collected.
|
| 2226 |
|
| 2227 |
*Effects:* The `n` bytes starting at `p` no longer contain traceable
|
| 2228 |
-
pointer locations, independent of their type. Hence
|
| 2229 |
-
|
| 2230 |
-
global `operator new` and not previously declared reachable.
|
| 2231 |
-
used to inform a garbage collector or leak detector that
|
| 2232 |
-
memory need not be traced.
|
| 2233 |
|
| 2234 |
*Throws:* Nothing.
|
| 2235 |
|
| 2236 |
Under some conditions implementations may need to allocate memory.
|
| 2237 |
However, the request can be ignored if memory allocation fails.
|
|
@@ -2288,11 +2499,11 @@ arguments for the same buffer.
|
|
| 2288 |
### Allocator argument tag <a id="allocator.tag">[[allocator.tag]]</a>
|
| 2289 |
|
| 2290 |
``` cpp
|
| 2291 |
namespace std {
|
| 2292 |
struct allocator_arg_t { };
|
| 2293 |
-
constexpr allocator_arg_t allocator_arg
|
| 2294 |
}
|
| 2295 |
```
|
| 2296 |
|
| 2297 |
The `allocator_arg_t` struct is an empty structure type used as a unique
|
| 2298 |
type to disambiguate constructor and function overloading. Specifically,
|
|
@@ -2386,11 +2597,11 @@ namespace std {
|
|
| 2386 |
static void construct(Alloc& a, T* p, Args&&... args);
|
| 2387 |
|
| 2388 |
template <class T>
|
| 2389 |
static void destroy(Alloc& a, T* p);
|
| 2390 |
|
| 2391 |
-
static size_type max_size(const Alloc& a);
|
| 2392 |
|
| 2393 |
static Alloc select_on_container_copy_construction(const Alloc& rhs);
|
| 2394 |
};
|
| 2395 |
}
|
| 2396 |
```
|
|
@@ -2435,11 +2646,11 @@ typedef see below difference_type;
|
|
| 2435 |
``` cpp
|
| 2436 |
typedef see below size_type;
|
| 2437 |
```
|
| 2438 |
|
| 2439 |
*Type:* `Alloc::size_type` if such a type exists; otherwise,
|
| 2440 |
-
`
|
| 2441 |
|
| 2442 |
``` cpp
|
| 2443 |
typedef see below propagate_on_container_copy_assignment;
|
| 2444 |
```
|
| 2445 |
|
|
@@ -2508,11 +2719,11 @@ template <class T>
|
|
| 2508 |
|
| 2509 |
*Effects:* calls `a.destroy(p)` if that call is well-formed; otherwise,
|
| 2510 |
invokes `p->~T()`.
|
| 2511 |
|
| 2512 |
``` cpp
|
| 2513 |
-
static size_type max_size(Alloc& a);
|
| 2514 |
```
|
| 2515 |
|
| 2516 |
*Returns:* `a.max_size()` if that expression is well-formed; otherwise,
|
| 2517 |
`numeric_limits<size_type>::max()`.
|
| 2518 |
|
|
@@ -2547,10 +2758,11 @@ namespace std {
|
|
| 2547 |
typedef const T* const_pointer;
|
| 2548 |
typedef T& reference;
|
| 2549 |
typedef const T& const_reference;
|
| 2550 |
typedef T value_type;
|
| 2551 |
template <class U> struct rebind { typedef allocator<U> other; };
|
|
|
|
| 2552 |
|
| 2553 |
allocator() noexcept;
|
| 2554 |
allocator(const allocator&) noexcept;
|
| 2555 |
template <class U> allocator(const allocator<U>&) noexcept;
|
| 2556 |
~allocator();
|
|
@@ -2622,11 +2834,12 @@ void deallocate(pointer p, size_type n);
|
|
| 2622 |
shall equal the value passed as the first argument to the invocation of
|
| 2623 |
allocate which returned `p`.
|
| 2624 |
|
| 2625 |
*Effects:* Deallocates the storage referenced by `p` .
|
| 2626 |
|
| 2627 |
-
*Remarks:* Uses
|
|
|
|
| 2628 |
unspecified when this function is called.
|
| 2629 |
|
| 2630 |
``` cpp
|
| 2631 |
size_type max_size() const noexcept;
|
| 2632 |
```
|
|
@@ -2665,11 +2878,11 @@ template <class T1, class T2>
|
|
| 2665 |
*Returns:* `false`.
|
| 2666 |
|
| 2667 |
### Raw storage iterator <a id="storage.iterator">[[storage.iterator]]</a>
|
| 2668 |
|
| 2669 |
`raw_storage_iterator` is provided to enable algorithms to store their
|
| 2670 |
-
results into uninitialized memory. The
|
| 2671 |
`OutputIterator` is required to have its `operator*` return an object
|
| 2672 |
for which `operator&` is defined and returns a pointer to `T`, and is
|
| 2673 |
also required to satisfy the requirements of an output iterator (
|
| 2674 |
[[output.iterators]]).
|
| 2675 |
|
|
@@ -2679,14 +2892,14 @@ namespace std {
|
|
| 2679 |
class raw_storage_iterator
|
| 2680 |
: public iterator<output_iterator_tag,void,void,void,void> {
|
| 2681 |
public:
|
| 2682 |
explicit raw_storage_iterator(OutputIterator x);
|
| 2683 |
|
| 2684 |
-
raw_storage_iterator
|
| 2685 |
-
raw_storage_iterator
|
| 2686 |
-
raw_storage_iterator
|
| 2687 |
-
raw_storage_iterator
|
| 2688 |
};
|
| 2689 |
}
|
| 2690 |
```
|
| 2691 |
|
| 2692 |
``` cpp
|
|
@@ -2695,33 +2908,33 @@ explicit raw_storage_iterator(OutputIterator x);
|
|
| 2695 |
|
| 2696 |
*Effects:* Initializes the iterator to point to the same value to which
|
| 2697 |
`x` points.
|
| 2698 |
|
| 2699 |
``` cpp
|
| 2700 |
-
raw_storage_iterator
|
| 2701 |
```
|
| 2702 |
|
| 2703 |
*Returns:* `*this`
|
| 2704 |
|
| 2705 |
``` cpp
|
| 2706 |
-
raw_storage_iterator
|
| 2707 |
```
|
| 2708 |
|
| 2709 |
*Effects:* Constructs a value from `element` at the location to which
|
| 2710 |
the iterator points.
|
| 2711 |
|
| 2712 |
*Returns:* A reference to the iterator.
|
| 2713 |
|
| 2714 |
``` cpp
|
| 2715 |
-
raw_storage_iterator
|
| 2716 |
```
|
| 2717 |
|
| 2718 |
*Effects:* Pre-increment: advances the iterator and returns a reference
|
| 2719 |
to the updated iterator.
|
| 2720 |
|
| 2721 |
``` cpp
|
| 2722 |
-
raw_storage_iterator
|
| 2723 |
```
|
| 2724 |
|
| 2725 |
*Effects:* Post-increment: advances the iterator and returns the old
|
| 2726 |
value of the iterator.
|
| 2727 |
|
|
@@ -2749,22 +2962,21 @@ template <class T> void return_temporary_buffer(T* p);
|
|
| 2749 |
*Requires:* The buffer shall have been previously allocated by
|
| 2750 |
`get_temporary_buffer`.
|
| 2751 |
|
| 2752 |
### Specialized algorithms <a id="specialized.algorithms">[[specialized.algorithms]]</a>
|
| 2753 |
|
| 2754 |
-
All the iterators that are used as
|
| 2755 |
-
|
| 2756 |
-
|
| 2757 |
-
|
| 2758 |
-
|
| 2759 |
-
|
| 2760 |
-
|
| 2761 |
-
|
| 2762 |
-
|
| 2763 |
-
|
| 2764 |
-
|
| 2765 |
-
effects.
|
| 2766 |
|
| 2767 |
#### `addressof` <a id="specialized.addressof">[[specialized.addressof]]</a>
|
| 2768 |
|
| 2769 |
``` cpp
|
| 2770 |
template <class T> T* addressof(T& r) noexcept;
|
|
@@ -2928,10 +3140,14 @@ namespace std {
|
|
| 2928 |
template<class T> struct default_delete<T[]>;
|
| 2929 |
|
| 2930 |
template<class T, class D = default_delete<T>> class unique_ptr;
|
| 2931 |
template<class T, class D> class unique_ptr<T[], D>;
|
| 2932 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2933 |
template<class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
|
| 2934 |
|
| 2935 |
template<class T1, class D1, class T2, class D2>
|
| 2936 |
bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 2937 |
template<class T1, class D1, class T2, class D2>
|
|
@@ -3063,11 +3279,11 @@ namespace std {
|
|
| 3063 |
unique_ptr& operator=(unique_ptr&& u) noexcept;
|
| 3064 |
template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
|
| 3065 |
unique_ptr& operator=(nullptr_t) noexcept;
|
| 3066 |
|
| 3067 |
// [unique.ptr.single.observers], observers
|
| 3068 |
-
|
| 3069 |
pointer operator->() const noexcept;
|
| 3070 |
pointer get() const noexcept;
|
| 3071 |
deleter_type& get_deleter() noexcept;
|
| 3072 |
const deleter_type& get_deleter() const noexcept;
|
| 3073 |
explicit operator bool() const noexcept;
|
|
@@ -3093,16 +3309,14 @@ is valid and has the effect of disposing of the pointer as appropriate
|
|
| 3093 |
for that deleter.
|
| 3094 |
|
| 3095 |
If the deleter’s type `D` is not a reference type, `D` shall satisfy the
|
| 3096 |
requirements of `Destructible` (Table [[destructible]]).
|
| 3097 |
|
| 3098 |
-
If the type `
|
| 3099 |
-
`
|
| 3100 |
-
D>::pointer` shall be a synonym for
|
| 3101 |
-
|
| 3102 |
-
`unique_ptr<T, D>::pointer` shall be a synonym for `T*`. The type
|
| 3103 |
-
`unique_ptr<T,
|
| 3104 |
D>::pointer` shall satisfy the requirements of `NullablePointer` (
|
| 3105 |
[[nullablepointer.requirements]]).
|
| 3106 |
|
| 3107 |
Given an allocator type `X` ([[allocator.requirements]]) and letting
|
| 3108 |
`A` be a synonym for `allocator_traits<X>`, the types `A::pointer`,
|
|
@@ -3298,18 +3512,17 @@ unique_ptr& operator=(unique_ptr&& u) noexcept;
|
|
| 3298 |
```
|
| 3299 |
|
| 3300 |
*Requires:* If `D` is not a reference type, `D` shall satisfy the
|
| 3301 |
requirements of `MoveAssignable` (Table [[moveassignable]]) and
|
| 3302 |
assignment of the deleter from an rvalue of type `D` shall not throw an
|
| 3303 |
-
exception. Otherwise, `D` is a reference type;
|
| 3304 |
-
|
| 3305 |
-
|
| 3306 |
-
shall not throw an exception.
|
| 3307 |
|
| 3308 |
*Effects:* Transfers ownership from `u` to `*this` as if by calling
|
| 3309 |
-
`reset(u.release())` followed by
|
| 3310 |
-
`std::forward<D>(u.get_deleter())`.
|
| 3311 |
|
| 3312 |
*Returns:* `*this`.
|
| 3313 |
|
| 3314 |
``` cpp
|
| 3315 |
template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
|
|
@@ -3326,12 +3539,12 @@ unless:
|
|
| 3326 |
|
| 3327 |
- `unique_ptr<U, E>::pointer` is implicitly convertible to `pointer` and
|
| 3328 |
- `U` is not an array type.
|
| 3329 |
|
| 3330 |
*Effects:* Transfers ownership from `u` to `*this` as if by calling
|
| 3331 |
-
`reset(u.release())` followed by
|
| 3332 |
-
`std::forward<
|
| 3333 |
|
| 3334 |
*Returns:* `*this`.
|
| 3335 |
|
| 3336 |
``` cpp
|
| 3337 |
unique_ptr& operator=(nullptr_t) noexcept;
|
|
@@ -3344,11 +3557,11 @@ unique_ptr& operator=(nullptr_t) noexcept;
|
|
| 3344 |
*Returns:* `*this`.
|
| 3345 |
|
| 3346 |
##### `unique_ptr` observers <a id="unique.ptr.single.observers">[[unique.ptr.single.observers]]</a>
|
| 3347 |
|
| 3348 |
``` cpp
|
| 3349 |
-
|
| 3350 |
```
|
| 3351 |
|
| 3352 |
*Requires:* `get() != nullptr`.
|
| 3353 |
|
| 3354 |
*Returns:* `*get()`.
|
|
@@ -3507,18 +3720,41 @@ stored pointer points.
|
|
| 3507 |
*Returns:* `get()[i]`.
|
| 3508 |
|
| 3509 |
##### `unique_ptr` modifiers <a id="unique.ptr.runtime.modifiers">[[unique.ptr.runtime.modifiers]]</a>
|
| 3510 |
|
| 3511 |
``` cpp
|
| 3512 |
-
void reset(pointer p = pointer()) noexcept;
|
| 3513 |
void reset(nullptr_t p) noexcept;
|
| 3514 |
```
|
| 3515 |
|
| 3516 |
-
*Effects:*
|
| 3517 |
-
`get_deleter()(get())`.
|
| 3518 |
|
| 3519 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3520 |
|
| 3521 |
#### `unique_ptr` specialized algorithms <a id="unique.ptr.special">[[unique.ptr.special]]</a>
|
| 3522 |
|
| 3523 |
``` cpp
|
| 3524 |
template <class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
|
|
@@ -3680,12 +3916,12 @@ namespace std {
|
|
| 3680 |
// [util.smartptr.shared.const], constructors:
|
| 3681 |
constexpr shared_ptr() noexcept;
|
| 3682 |
template<class Y> explicit shared_ptr(Y* p);
|
| 3683 |
template<class Y, class D> shared_ptr(Y* p, D d);
|
| 3684 |
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
|
| 3685 |
-
template <class D> shared_ptr(nullptr_t p, D d)
|
| 3686 |
-
template <class D, class A> shared_ptr(nullptr_t p, D d, A a)
|
| 3687 |
template<class Y> shared_ptr(const shared_ptr<Y>& r, T* p) noexcept;
|
| 3688 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 3689 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 3690 |
shared_ptr(shared_ptr&& r) noexcept;
|
| 3691 |
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
|
|
@@ -3812,11 +4048,11 @@ races.
|
|
| 3812 |
constexpr shared_ptr() noexcept;
|
| 3813 |
```
|
| 3814 |
|
| 3815 |
*Effects:* Constructs an *empty* `shared_ptr` object.
|
| 3816 |
|
| 3817 |
-
*Postconditions:* `use_count() == 0 && get() ==
|
| 3818 |
|
| 3819 |
``` cpp
|
| 3820 |
template<class Y> explicit shared_ptr(Y* p);
|
| 3821 |
```
|
| 3822 |
|
|
@@ -3870,19 +4106,19 @@ template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p) noexcept;
|
|
| 3870 |
To avoid the possibility of a dangling pointer, the user of this
|
| 3871 |
constructor must ensure that `p` remains valid at least until the
|
| 3872 |
ownership group of `r` is destroyed.
|
| 3873 |
|
| 3874 |
This constructor allows creation of an *empty* `shared_ptr` instance
|
| 3875 |
-
with a non-
|
| 3876 |
|
| 3877 |
``` cpp
|
| 3878 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 3879 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 3880 |
```
|
| 3881 |
|
| 3882 |
-
|
| 3883 |
-
|
| 3884 |
|
| 3885 |
*Effects:* If `r` is *empty*, constructs an *empty* `shared_ptr` object;
|
| 3886 |
otherwise, constructs a `shared_ptr` object that *shares ownership* with
|
| 3887 |
`r`.
|
| 3888 |
|
|
@@ -3897,11 +4133,11 @@ The second constructor shall not participate in overload resolution
|
|
| 3897 |
unless `Y*` is convertible to `T*`.
|
| 3898 |
|
| 3899 |
*Effects:* Move-constructs a `shared_ptr` instance from `r`.
|
| 3900 |
|
| 3901 |
*Postconditions:* `*this` shall contain the old value of `r`. `r` shall
|
| 3902 |
-
be *empty*. `r.get() ==
|
| 3903 |
|
| 3904 |
``` cpp
|
| 3905 |
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
|
| 3906 |
```
|
| 3907 |
|
|
@@ -3925,11 +4161,11 @@ complete type. The expression `delete r.release()` shall be well formed,
|
|
| 3925 |
shall have well defined behavior, and shall not throw exceptions.
|
| 3926 |
|
| 3927 |
*Effects:* Constructs a `shared_ptr` object that stores and *owns*
|
| 3928 |
`r.release()`.
|
| 3929 |
|
| 3930 |
-
*Postconditions:* `use_count() == 1` `&&` `r.get() ==
|
| 3931 |
|
| 3932 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 3933 |
resource other than memory could not be obtained.
|
| 3934 |
|
| 3935 |
If an exception is thrown, the constructor has no effect.
|
|
@@ -4082,11 +4318,11 @@ bool unique() const noexcept;
|
|
| 4082 |
|
| 4083 |
*Returns:* `use_count() == 1`.
|
| 4084 |
|
| 4085 |
`unique()` may be faster than `use_count()`. If you are using `unique()`
|
| 4086 |
to implement copy on write, do not rely on a specific value when
|
| 4087 |
-
`get() ==
|
| 4088 |
|
| 4089 |
``` cpp
|
| 4090 |
explicit operator bool() const noexcept;
|
| 4091 |
```
|
| 4092 |
|
|
@@ -4132,13 +4368,13 @@ the newly constructed object of type `T`.
|
|
| 4132 |
*Postconditions:* `get() != 0 && use_count() == 1`
|
| 4133 |
|
| 4134 |
*Throws:* `bad_alloc`, or an exception thrown from `A::allocate` or from
|
| 4135 |
the constructor of `T`.
|
| 4136 |
|
| 4137 |
-
*Remarks:* Implementations
|
| 4138 |
-
|
| 4139 |
-
|
| 4140 |
|
| 4141 |
These functions will typically allocate more memory than `sizeof(T)` to
|
| 4142 |
allow for internal bookkeeping structures such as the reference counts.
|
| 4143 |
|
| 4144 |
##### `shared_ptr` comparison <a id="util.smartptr.shared.cmp">[[util.smartptr.shared.cmp]]</a>
|
|
@@ -4152,11 +4388,11 @@ template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_
|
|
| 4152 |
``` cpp
|
| 4153 |
template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
|
| 4154 |
```
|
| 4155 |
|
| 4156 |
*Returns:* `less<V>()(a.get(), b.get())`, where `V` is the composite
|
| 4157 |
-
pointer type
|
| 4158 |
|
| 4159 |
Defining a comparison operator allows `shared_ptr` objects to be used as
|
| 4160 |
keys in associative containers.
|
| 4161 |
|
| 4162 |
``` cpp
|
|
@@ -4289,14 +4525,14 @@ undefined behavior, attempting to delete the same object twice.
|
|
| 4289 |
``` cpp
|
| 4290 |
template<class D, class T> D* get_deleter(const shared_ptr<T>& p) noexcept;
|
| 4291 |
```
|
| 4292 |
|
| 4293 |
*Returns:* If `p` *owns* a deleter `d` of type cv-unqualified `D`,
|
| 4294 |
-
returns `&d`; otherwise returns `
|
| 4295 |
-
as long as there exists a `shared_ptr` instance that owns `d`. It
|
| 4296 |
-
unspecified whether the pointer remains valid longer than that. This
|
| 4297 |
-
happen if the implementation doesn’t destroy the deleter until all
|
| 4298 |
`weak_ptr` instances that share ownership with `p` have been destroyed.
|
| 4299 |
|
| 4300 |
##### `shared_ptr` I/O <a id="util.smartptr.shared.io">[[util.smartptr.shared.io]]</a>
|
| 4301 |
|
| 4302 |
``` cpp
|
|
@@ -4323,29 +4559,33 @@ namespace std {
|
|
| 4323 |
// [util.smartptr.weak.const], constructors
|
| 4324 |
constexpr weak_ptr() noexcept;
|
| 4325 |
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
|
| 4326 |
weak_ptr(weak_ptr const& r) noexcept;
|
| 4327 |
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
|
|
|
|
|
|
|
| 4328 |
|
| 4329 |
// [util.smartptr.weak.dest], destructor
|
| 4330 |
~weak_ptr();
|
| 4331 |
|
| 4332 |
// [util.smartptr.weak.assign], assignment
|
| 4333 |
weak_ptr& operator=(weak_ptr const& r) noexcept;
|
| 4334 |
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
|
| 4335 |
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
|
|
|
|
|
|
|
| 4336 |
|
| 4337 |
// [util.smartptr.weak.mod], modifiers
|
| 4338 |
void swap(weak_ptr& r) noexcept;
|
| 4339 |
void reset() noexcept;
|
| 4340 |
|
| 4341 |
// [util.smartptr.weak.obs], observers
|
| 4342 |
long use_count() const noexcept;
|
| 4343 |
bool expired() const noexcept;
|
| 4344 |
shared_ptr<T> lock() const noexcept;
|
| 4345 |
-
template<class U> bool owner_before(shared_ptr<U> const& b);
|
| 4346 |
-
template<class U> bool owner_before(weak_ptr<U> const& b);
|
| 4347 |
};
|
| 4348 |
|
| 4349 |
// [util.smartptr.weak.spec], specialized algorithms
|
| 4350 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 4351 |
} // namespace std
|
|
@@ -4369,19 +4609,32 @@ constexpr weak_ptr() noexcept;
|
|
| 4369 |
weak_ptr(const weak_ptr& r) noexcept;
|
| 4370 |
template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept;
|
| 4371 |
template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept;
|
| 4372 |
```
|
| 4373 |
|
| 4374 |
-
|
| 4375 |
-
|
| 4376 |
|
| 4377 |
*Effects:* If `r` is *empty*, constructs an *empty* `weak_ptr` object;
|
| 4378 |
otherwise, constructs a `weak_ptr` object that *shares ownership* with
|
| 4379 |
`r` and stores a copy of the pointer stored in `r`.
|
| 4380 |
|
| 4381 |
*Postconditions:* `use_count() == r.use_count()`.
|
| 4382 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4383 |
##### `weak_ptr` destructor <a id="util.smartptr.weak.dest">[[util.smartptr.weak.dest]]</a>
|
| 4384 |
|
| 4385 |
``` cpp
|
| 4386 |
~weak_ptr();
|
| 4387 |
```
|
|
@@ -4400,10 +4653,21 @@ template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
|
|
| 4400 |
*Effects:* Equivalent to `weak_ptr(r).swap(*this)`.
|
| 4401 |
|
| 4402 |
*Remarks:* The implementation may meet the effects (and the implied
|
| 4403 |
guarantees) via different means, without creating a temporary.
|
| 4404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4405 |
##### `weak_ptr` modifiers <a id="util.smartptr.weak.mod">[[util.smartptr.weak.mod]]</a>
|
| 4406 |
|
| 4407 |
``` cpp
|
| 4408 |
void swap(weak_ptr& r) noexcept;
|
| 4409 |
```
|
|
@@ -4437,15 +4701,16 @@ bool expired() const noexcept;
|
|
| 4437 |
|
| 4438 |
``` cpp
|
| 4439 |
shared_ptr<T> lock() const noexcept;
|
| 4440 |
```
|
| 4441 |
|
| 4442 |
-
*Returns:* `expired() ? shared_ptr<T>() : shared_ptr<T>(*this)`
|
|
|
|
| 4443 |
|
| 4444 |
``` cpp
|
| 4445 |
-
template<class U> bool owner_before(shared_ptr<U> const& b);
|
| 4446 |
-
template<class U> bool owner_before(weak_ptr<U> const& b);
|
| 4447 |
```
|
| 4448 |
|
| 4449 |
*Returns:* An unspecified value such that
|
| 4450 |
|
| 4451 |
- `x.owner_before(y)` defines a strict weak ordering as defined
|
|
@@ -4461,11 +4726,11 @@ template<class U> bool owner_before(weak_ptr<U> const& b);
|
|
| 4461 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 4462 |
```
|
| 4463 |
|
| 4464 |
*Effects:* Equivalent to `a.swap(b)`.
|
| 4465 |
|
| 4466 |
-
####
|
| 4467 |
|
| 4468 |
The class template `owner_less` allows ownership-based mixed comparisons
|
| 4469 |
of shared and weak pointers.
|
| 4470 |
|
| 4471 |
``` cpp
|
|
@@ -4692,11 +4957,11 @@ template<class T>
|
|
| 4692 |
template<class T>
|
| 4693 |
bool atomic_compare_exchange_weak(
|
| 4694 |
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
|
| 4695 |
```
|
| 4696 |
|
| 4697 |
-
*Requires:* `p` shall not be null.
|
| 4698 |
|
| 4699 |
*Returns:*
|
| 4700 |
`atomic_compare_exchange_weak_explicit(p, v, w, memory_order_seq_cst, memory_order_seq_cst)`.
|
| 4701 |
|
| 4702 |
*Throws:* Nothing.
|
|
@@ -4719,11 +4984,11 @@ template<class T>
|
|
| 4719 |
bool atomic_compare_exchange_strong_explicit(
|
| 4720 |
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
|
| 4721 |
memory_order success, memory_order failure);
|
| 4722 |
```
|
| 4723 |
|
| 4724 |
-
*Requires:* `p` shall not be null.
|
| 4725 |
|
| 4726 |
*Requires:* `failure` shall not be `memory_order_release`,
|
| 4727 |
`memory_order_acq_rel`, or stronger than `success`.
|
| 4728 |
|
| 4729 |
*Effects:* If `*p` is equivalent to `*v`, assigns `w` to `*p` and has
|
|
@@ -4745,22 +5010,25 @@ See [[atomics.types.operations]].
|
|
| 4745 |
|
| 4746 |
``` cpp
|
| 4747 |
template <class T, class D> struct hash<unique_ptr<T, D> >;
|
| 4748 |
```
|
| 4749 |
|
| 4750 |
-
|
| 4751 |
-
|
| 4752 |
-
|
| 4753 |
-
|
| 4754 |
-
|
|
|
|
|
|
|
|
|
|
| 4755 |
|
| 4756 |
``` cpp
|
| 4757 |
template <class T> struct hash<shared_ptr<T> >;
|
| 4758 |
```
|
| 4759 |
|
| 4760 |
-
|
| 4761 |
-
|
| 4762 |
`shared_ptr<T>`, `hash<shared_ptr<T> >()(p)` shall evaluate to the same
|
| 4763 |
value as `hash<T*>()(p.get())`.
|
| 4764 |
|
| 4765 |
## Function objects <a id="function.objects">[[function.objects]]</a>
|
| 4766 |
|
|
@@ -4790,44 +5058,64 @@ namespace std {
|
|
| 4790 |
|
| 4791 |
template <class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
|
| 4792 |
template <class T> reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
|
| 4793 |
|
| 4794 |
// [arithmetic.operations], arithmetic operations:
|
| 4795 |
-
template <class T> struct plus;
|
| 4796 |
-
template <class T> struct minus;
|
| 4797 |
-
template <class T> struct multiplies;
|
| 4798 |
-
template <class T> struct divides;
|
| 4799 |
-
template <class T> struct modulus;
|
| 4800 |
-
template <class T> struct negate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4801 |
|
| 4802 |
// [comparisons], comparisons:
|
| 4803 |
-
template <class T> struct equal_to;
|
| 4804 |
-
template <class T> struct not_equal_to;
|
| 4805 |
-
template <class T> struct greater;
|
| 4806 |
-
template <class T> struct less;
|
| 4807 |
-
template <class T> struct greater_equal;
|
| 4808 |
-
template <class T> struct less_equal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4809 |
|
| 4810 |
// [logical.operations], logical operations:
|
| 4811 |
-
template <class T> struct logical_and;
|
| 4812 |
-
template <class T> struct logical_or;
|
| 4813 |
-
template <class T> struct logical_not;
|
|
|
|
|
|
|
|
|
|
| 4814 |
|
| 4815 |
// [bitwise.operations], bitwise operations:
|
| 4816 |
-
template <class T> struct bit_and;
|
| 4817 |
-
template <class T> struct bit_or;
|
| 4818 |
-
template <class T> struct bit_xor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4819 |
|
| 4820 |
// [negators], negators:
|
| 4821 |
template <class Predicate> class unary_negate;
|
| 4822 |
template <class Predicate>
|
| 4823 |
-
unary_negate<Predicate>
|
| 4824 |
template <class Predicate> class binary_negate;
|
| 4825 |
template <class Predicate>
|
| 4826 |
-
binary_negate<Predicate> not2(const Predicate&);
|
| 4827 |
|
| 4828 |
-
// [bind], bind:
|
| 4829 |
template<class T> struct is_bind_expression;
|
| 4830 |
template<class T> struct is_placeholder;
|
| 4831 |
|
| 4832 |
template<class F, class... BoundArgs>
|
| 4833 |
unspecified bind(F&&, BoundArgs&&...);
|
|
@@ -4889,34 +5177,10 @@ namespace std {
|
|
| 4889 |
template <class S, class T, class A>
|
| 4890 |
const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
|
| 4891 |
|
| 4892 |
// [func.memfn], member function adaptors:
|
| 4893 |
template<class R, class T> unspecified mem_fn(R T::*);
|
| 4894 |
-
template<class R, class T, class... Args>
|
| 4895 |
-
unspecified mem_fn(R (T::*)(Args...));
|
| 4896 |
-
template<class R, class T, class... Args>
|
| 4897 |
-
unspecified mem_fn(R (T::*)(Args...) const);
|
| 4898 |
-
template<class R, class T, class... Args>
|
| 4899 |
-
unspecified mem_fn(R (T::*)(Args...) volatile);
|
| 4900 |
-
template<class R, class T, class... Args>
|
| 4901 |
-
unspecified mem_fn(R (T::*)(Args...) const volatile);
|
| 4902 |
-
template<class R, class T, class... Args>
|
| 4903 |
-
unspecified mem_fn(R (T::*)(Args...) &);
|
| 4904 |
-
template<class R, class T, class... Args>
|
| 4905 |
-
unspecified mem_fn(R (T::*)(Args...) const &);
|
| 4906 |
-
template<class R, class T, class... Args>
|
| 4907 |
-
unspecified mem_fn(R (T::*)(Args...) volatile &);
|
| 4908 |
-
template<class R, class T, class... Args>
|
| 4909 |
-
unspecified mem_fn(R (T::*)(Args...) const volatile &);
|
| 4910 |
-
template<class R, class T, class... Args>
|
| 4911 |
-
unspecified mem_fn(R (T::*)(Args...) &&);
|
| 4912 |
-
template<class R, class T, class... Args>
|
| 4913 |
-
unspecified mem_fn(R (T::*)(Args...) const &&);
|
| 4914 |
-
template<class R, class T, class... Args>
|
| 4915 |
-
unspecified mem_fn(R (T::*)(Args...) volatile &&);
|
| 4916 |
-
template<class R, class T, class... Args>
|
| 4917 |
-
unspecified mem_fn(R (T::*)(Args...) const volatile &&);
|
| 4918 |
|
| 4919 |
// [func.wrap] polymorphic function wrappers:
|
| 4920 |
class bad_function_call;
|
| 4921 |
|
| 4922 |
template<class> class function; // undefined
|
|
@@ -4932,11 +5196,11 @@ namespace std {
|
|
| 4932 |
template<class R, class... ArgTypes>
|
| 4933 |
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
|
| 4934 |
template<class R, class... ArgTypes>
|
| 4935 |
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
|
| 4936 |
|
| 4937 |
-
// [unord.hash], hash function
|
| 4938 |
template <class T> struct hash;
|
| 4939 |
|
| 4940 |
// Hash function specializations
|
| 4941 |
template <> struct hash<bool>;
|
| 4942 |
template <> struct hash<char>;
|
|
@@ -4974,15 +5238,15 @@ To negate every element of `a`:
|
|
| 4974 |
``` cpp
|
| 4975 |
transform(a.begin(), a.end(), a.begin(), negate<double>());
|
| 4976 |
```
|
| 4977 |
|
| 4978 |
To enable adaptors and other components to manipulate function objects
|
| 4979 |
-
that take one or two arguments
|
| 4980 |
-
correspondingly provide typedefs `argument_type` and
|
| 4981 |
-
function objects that take one argument and
|
| 4982 |
-
`second_argument_type`, and `result_type` for
|
| 4983 |
-
two arguments.
|
| 4984 |
|
| 4985 |
### Definitions <a id="func.def">[[func.def]]</a>
|
| 4986 |
|
| 4987 |
The following definitions apply to this Clause:
|
| 4988 |
|
|
@@ -5065,22 +5329,22 @@ namespace std {
|
|
| 5065 |
typedef see below second_argument_type; // not always defined
|
| 5066 |
|
| 5067 |
// construct/copy/destroy
|
| 5068 |
reference_wrapper(T&) noexcept;
|
| 5069 |
reference_wrapper(T&&) = delete; // do not bind to temporary objects
|
| 5070 |
-
reference_wrapper(const reference_wrapper
|
| 5071 |
|
| 5072 |
// assignment
|
| 5073 |
-
reference_wrapper& operator=(const reference_wrapper
|
| 5074 |
|
| 5075 |
// access
|
| 5076 |
operator T& () const noexcept;
|
| 5077 |
T& get() const noexcept;
|
| 5078 |
|
| 5079 |
// invocation
|
| 5080 |
template <class... ArgTypes>
|
| 5081 |
-
|
| 5082 |
operator() (ArgTypes&&...) const;
|
| 5083 |
};
|
| 5084 |
}
|
| 5085 |
```
|
| 5086 |
|
|
@@ -5089,11 +5353,11 @@ wrapper around a reference to an object or function of type `T`.
|
|
| 5089 |
|
| 5090 |
`reference_wrapper<T>` has a weak result type ([[func.require]]). If
|
| 5091 |
`T` is a function type, `result_type` shall be a synonym for the return
|
| 5092 |
type of `T`.
|
| 5093 |
|
| 5094 |
-
The template
|
| 5095 |
type named `argument_type` as a synonym for `T1` only if the type `T` is
|
| 5096 |
any of the following:
|
| 5097 |
|
| 5098 |
- a function type or a pointer to function type taking one argument of
|
| 5099 |
type `T1`
|
|
@@ -5110,11 +5374,11 @@ the following:
|
|
| 5110 |
- a function type or a pointer to function type taking two arguments of
|
| 5111 |
types `T1` and `T2`
|
| 5112 |
- a pointer to member function `R T0::f(T2)` *cv* (where *cv* represents
|
| 5113 |
the member function’s cv-qualifiers); the type `T1` is *cv* `T0*`
|
| 5114 |
- a class type with member types `first_argument_type` and
|
| 5115 |
-
`second_argument_type`; the type `T1` is `T::first_argument_type`
|
| 5116 |
the type `T2` is `T::second_argument_type`.
|
| 5117 |
|
| 5118 |
#### `reference_wrapper` construct/copy/destroy <a id="refwrap.const">[[refwrap.const]]</a>
|
| 5119 |
|
| 5120 |
``` cpp
|
|
@@ -5123,20 +5387,20 @@ reference_wrapper(T& t) noexcept;
|
|
| 5123 |
|
| 5124 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 5125 |
reference to `t`.
|
| 5126 |
|
| 5127 |
``` cpp
|
| 5128 |
-
reference_wrapper(const reference_wrapper
|
| 5129 |
```
|
| 5130 |
|
| 5131 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 5132 |
reference to `x.get()`.
|
| 5133 |
|
| 5134 |
#### `reference_wrapper` assignment <a id="refwrap.assign">[[refwrap.assign]]</a>
|
| 5135 |
|
| 5136 |
``` cpp
|
| 5137 |
-
reference_wrapper& operator=(const reference_wrapper
|
| 5138 |
```
|
| 5139 |
|
| 5140 |
*Postconditions:* `*this` stores a reference to `x.get()`.
|
| 5141 |
|
| 5142 |
#### `reference_wrapper` access <a id="refwrap.access">[[refwrap.access]]</a>
|
|
@@ -5155,11 +5419,11 @@ T& get() const noexcept;
|
|
| 5155 |
|
| 5156 |
#### reference_wrapper invocation <a id="refwrap.invoke">[[refwrap.invoke]]</a>
|
| 5157 |
|
| 5158 |
``` cpp
|
| 5159 |
template <class... ArgTypes>
|
| 5160 |
-
|
| 5161 |
operator()(ArgTypes&&... args) const;
|
| 5162 |
```
|
| 5163 |
|
| 5164 |
*Returns:*
|
| 5165 |
*`INVOKE`*`(get(), std::forward<ArgTypes>(args)...)`. ([[func.require]])
|
|
@@ -5199,145 +5463,277 @@ template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexc
|
|
| 5199 |
|
| 5200 |
The library provides basic function object classes for all of the
|
| 5201 |
arithmetic operators in the language ([[expr.mul]], [[expr.add]]).
|
| 5202 |
|
| 5203 |
``` cpp
|
| 5204 |
-
template <class T> struct plus {
|
| 5205 |
-
T operator()(const T& x, const T& y) const;
|
| 5206 |
typedef T first_argument_type;
|
| 5207 |
typedef T second_argument_type;
|
| 5208 |
typedef T result_type;
|
| 5209 |
};
|
| 5210 |
```
|
| 5211 |
|
| 5212 |
`operator()` returns `x + y`.
|
| 5213 |
|
| 5214 |
``` cpp
|
| 5215 |
-
template <class T> struct minus {
|
| 5216 |
-
T operator()(const T& x, const T& y) const;
|
| 5217 |
typedef T first_argument_type;
|
| 5218 |
typedef T second_argument_type;
|
| 5219 |
typedef T result_type;
|
| 5220 |
};
|
| 5221 |
```
|
| 5222 |
|
| 5223 |
`operator()` returns `x - y`.
|
| 5224 |
|
| 5225 |
``` cpp
|
| 5226 |
-
template <class T> struct multiplies {
|
| 5227 |
-
T operator()(const T& x, const T& y) const;
|
| 5228 |
typedef T first_argument_type;
|
| 5229 |
typedef T second_argument_type;
|
| 5230 |
typedef T result_type;
|
| 5231 |
};
|
| 5232 |
```
|
| 5233 |
|
| 5234 |
`operator()` returns `x * y`.
|
| 5235 |
|
| 5236 |
``` cpp
|
| 5237 |
-
template <class T> struct divides {
|
| 5238 |
-
T operator()(const T& x, const T& y) const;
|
| 5239 |
typedef T first_argument_type;
|
| 5240 |
typedef T second_argument_type;
|
| 5241 |
typedef T result_type;
|
| 5242 |
};
|
| 5243 |
```
|
| 5244 |
|
| 5245 |
`operator()` returns `x / y`.
|
| 5246 |
|
| 5247 |
``` cpp
|
| 5248 |
-
template <class T> struct modulus {
|
| 5249 |
-
T operator()(const T& x, const T& y) const;
|
| 5250 |
typedef T first_argument_type;
|
| 5251 |
typedef T second_argument_type;
|
| 5252 |
typedef T result_type;
|
| 5253 |
};
|
| 5254 |
```
|
| 5255 |
|
| 5256 |
`operator()` returns `x % y`.
|
| 5257 |
|
| 5258 |
``` cpp
|
| 5259 |
-
template <class T> struct negate {
|
| 5260 |
-
T operator()(const T& x) const;
|
| 5261 |
typedef T argument_type;
|
| 5262 |
typedef T result_type;
|
| 5263 |
};
|
| 5264 |
```
|
| 5265 |
|
| 5266 |
`operator()` returns `-x`.
|
| 5267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5268 |
### Comparisons <a id="comparisons">[[comparisons]]</a>
|
| 5269 |
|
| 5270 |
The library provides basic function object classes for all of the
|
| 5271 |
comparison operators in the language ([[expr.rel]], [[expr.eq]]).
|
| 5272 |
|
| 5273 |
``` cpp
|
| 5274 |
-
template <class T> struct equal_to {
|
| 5275 |
-
bool operator()(const T& x, const T& y) const;
|
| 5276 |
typedef T first_argument_type;
|
| 5277 |
typedef T second_argument_type;
|
| 5278 |
typedef bool result_type;
|
| 5279 |
};
|
| 5280 |
```
|
| 5281 |
|
| 5282 |
`operator()` returns `x == y`.
|
| 5283 |
|
| 5284 |
``` cpp
|
| 5285 |
-
template <class T> struct not_equal_to {
|
| 5286 |
-
bool operator()(const T& x, const T& y) const;
|
| 5287 |
typedef T first_argument_type;
|
| 5288 |
typedef T second_argument_type;
|
| 5289 |
typedef bool result_type;
|
| 5290 |
};
|
| 5291 |
```
|
| 5292 |
|
| 5293 |
`operator()` returns `x != y`.
|
| 5294 |
|
| 5295 |
``` cpp
|
| 5296 |
-
template <class T> struct greater {
|
| 5297 |
-
bool operator()(const T& x, const T& y) const;
|
| 5298 |
typedef T first_argument_type;
|
| 5299 |
typedef T second_argument_type;
|
| 5300 |
typedef bool result_type;
|
| 5301 |
};
|
| 5302 |
```
|
| 5303 |
|
| 5304 |
`operator()` returns `x > y`.
|
| 5305 |
|
| 5306 |
``` cpp
|
| 5307 |
-
template <class T> struct less {
|
| 5308 |
-
bool operator()(const T& x, const T& y) const;
|
| 5309 |
typedef T first_argument_type;
|
| 5310 |
typedef T second_argument_type;
|
| 5311 |
typedef bool result_type;
|
| 5312 |
};
|
| 5313 |
```
|
| 5314 |
|
| 5315 |
`operator()` returns `x < y`.
|
| 5316 |
|
| 5317 |
``` cpp
|
| 5318 |
-
template <class T> struct greater_equal {
|
| 5319 |
-
bool operator()(const T& x, const T& y) const;
|
| 5320 |
typedef T first_argument_type;
|
| 5321 |
typedef T second_argument_type;
|
| 5322 |
typedef bool result_type;
|
| 5323 |
};
|
| 5324 |
```
|
| 5325 |
|
| 5326 |
`operator()` returns `x >= y`.
|
| 5327 |
|
| 5328 |
``` cpp
|
| 5329 |
-
template <class T> struct less_equal {
|
| 5330 |
-
bool operator()(const T& x, const T& y) const;
|
| 5331 |
typedef T first_argument_type;
|
| 5332 |
typedef T second_argument_type;
|
| 5333 |
typedef bool result_type;
|
| 5334 |
};
|
| 5335 |
```
|
| 5336 |
|
| 5337 |
`operator()` returns `x <= y`.
|
| 5338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5339 |
For templates `greater`, `less`, `greater_equal`, and `less_equal`, the
|
| 5340 |
specializations for any pointer type yield a total order, even if the
|
| 5341 |
built-in operators `<`, `>`, `<=`, `>=` do not.
|
| 5342 |
|
| 5343 |
### Logical operations <a id="logical.operations">[[logical.operations]]</a>
|
|
@@ -5345,111 +5741,198 @@ built-in operators `<`, `>`, `<=`, `>=` do not.
|
|
| 5345 |
The library provides basic function object classes for all of the
|
| 5346 |
logical operators in the language ([[expr.log.and]], [[expr.log.or]],
|
| 5347 |
[[expr.unary.op]]).
|
| 5348 |
|
| 5349 |
``` cpp
|
| 5350 |
-
template <class T> struct logical_and {
|
| 5351 |
-
bool operator()(const T& x, const T& y) const;
|
| 5352 |
typedef T first_argument_type;
|
| 5353 |
typedef T second_argument_type;
|
| 5354 |
typedef bool result_type;
|
| 5355 |
};
|
| 5356 |
```
|
| 5357 |
|
| 5358 |
`operator()` returns `x && y`.
|
| 5359 |
|
| 5360 |
``` cpp
|
| 5361 |
-
template <class T> struct logical_or {
|
| 5362 |
-
bool operator()(const T& x, const T& y) const;
|
| 5363 |
typedef T first_argument_type;
|
| 5364 |
typedef T second_argument_type;
|
| 5365 |
typedef bool result_type;
|
| 5366 |
};
|
| 5367 |
```
|
| 5368 |
|
| 5369 |
`operator()` returns `x || y`.
|
| 5370 |
|
| 5371 |
``` cpp
|
| 5372 |
-
template <class T> struct logical_not {
|
| 5373 |
-
bool operator()(const T& x) const;
|
| 5374 |
typedef T argument_type;
|
| 5375 |
typedef bool result_type;
|
| 5376 |
};
|
| 5377 |
```
|
| 5378 |
|
| 5379 |
`operator()` returns `!x`.
|
| 5380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5381 |
### Bitwise operations <a id="bitwise.operations">[[bitwise.operations]]</a>
|
| 5382 |
|
| 5383 |
The library provides basic function object classes for all of the
|
| 5384 |
bitwise operators in the language ([[expr.bit.and]], [[expr.or]],
|
| 5385 |
-
[[expr.xor]]).
|
| 5386 |
|
| 5387 |
``` cpp
|
| 5388 |
-
template <class T> struct bit_and {
|
| 5389 |
-
T operator()(const T& x, const T& y) const;
|
| 5390 |
typedef T first_argument_type;
|
| 5391 |
typedef T second_argument_type;
|
| 5392 |
typedef T result_type;
|
| 5393 |
};
|
| 5394 |
```
|
| 5395 |
|
| 5396 |
`operator()` returns `x & y`.
|
| 5397 |
|
| 5398 |
``` cpp
|
| 5399 |
-
template <class T> struct bit_or {
|
| 5400 |
-
T operator()(const T& x, const T& y) const;
|
| 5401 |
typedef T first_argument_type;
|
| 5402 |
typedef T second_argument_type;
|
| 5403 |
typedef T result_type;
|
| 5404 |
};
|
| 5405 |
```
|
| 5406 |
|
| 5407 |
`operator()` returns `x | y`.
|
| 5408 |
|
| 5409 |
``` cpp
|
| 5410 |
-
template <class T> struct bit_xor {
|
| 5411 |
-
T operator()(const T& x, const T& y) const;
|
| 5412 |
typedef T first_argument_type;
|
| 5413 |
typedef T second_argument_type;
|
| 5414 |
typedef T result_type;
|
| 5415 |
};
|
| 5416 |
```
|
| 5417 |
|
| 5418 |
`operator()` returns `x ^ y`.
|
| 5419 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5420 |
### Negators <a id="negators">[[negators]]</a>
|
| 5421 |
|
| 5422 |
Negators `not1` and `not2` take a unary and a binary predicate,
|
| 5423 |
respectively, and return their complements ([[expr.unary.op]]).
|
| 5424 |
|
| 5425 |
``` cpp
|
| 5426 |
template <class Predicate>
|
| 5427 |
class unary_negate {
|
| 5428 |
public:
|
| 5429 |
-
explicit unary_negate(const Predicate& pred);
|
| 5430 |
-
bool operator()(const typename Predicate::argument_type& x) const;
|
| 5431 |
typedef typename Predicate::argument_type argument_type;
|
| 5432 |
typedef bool result_type;
|
| 5433 |
};
|
| 5434 |
```
|
| 5435 |
|
| 5436 |
`operator()` returns `!pred(x)`.
|
| 5437 |
|
| 5438 |
``` cpp
|
| 5439 |
template <class Predicate>
|
| 5440 |
-
unary_negate<Predicate> not1(const Predicate& pred);
|
| 5441 |
```
|
| 5442 |
|
| 5443 |
*Returns:* `unary_negate<Predicate>(pred)`.
|
| 5444 |
|
| 5445 |
``` cpp
|
| 5446 |
template <class Predicate>
|
| 5447 |
class binary_negate {
|
| 5448 |
public:
|
| 5449 |
-
explicit binary_negate(const Predicate& pred);
|
| 5450 |
-
bool operator()(const typename Predicate::first_argument_type&
|
| 5451 |
const typename Predicate::second_argument_type& y) const;
|
| 5452 |
typedef typename Predicate::first_argument_type first_argument_type;
|
| 5453 |
typedef typename Predicate::second_argument_type second_argument_type;
|
| 5454 |
typedef bool result_type;
|
| 5455 |
};
|
|
@@ -5457,60 +5940,70 @@ template <class Predicate>
|
|
| 5457 |
|
| 5458 |
`operator()` returns `!pred(x,y)`.
|
| 5459 |
|
| 5460 |
``` cpp
|
| 5461 |
template <class Predicate>
|
| 5462 |
-
binary_negate<Predicate> not2(const Predicate& pred);
|
| 5463 |
```
|
| 5464 |
|
| 5465 |
*Returns:* `binary_negate<Predicate>(pred)`.
|
| 5466 |
|
| 5467 |
-
### Function
|
| 5468 |
-
|
| 5469 |
-
The function template `bind` returns an object that binds a callable
|
| 5470 |
-
object passed as an argument to additional arguments.
|
| 5471 |
-
|
| 5472 |
-
#### Function object binders <a id="func.bind">[[func.bind]]</a>
|
| 5473 |
|
| 5474 |
This subclause describes a uniform mechanism for binding arguments of
|
| 5475 |
callable objects.
|
| 5476 |
|
| 5477 |
-
####
|
| 5478 |
|
| 5479 |
``` cpp
|
| 5480 |
namespace std {
|
| 5481 |
-
template<class T> struct is_bind_expression
|
| 5482 |
-
: integral_constant<bool, see below> { };
|
| 5483 |
}
|
| 5484 |
```
|
| 5485 |
|
| 5486 |
`is_bind_expression` can be used to detect function objects generated by
|
| 5487 |
-
`bind`. `bind` uses `is_bind_expression` to detect subexpressions.
|
| 5488 |
-
may specialize this template to indicate that a type should be treated
|
| 5489 |
-
as a subexpression in a `bind` call.
|
| 5490 |
|
| 5491 |
-
|
| 5492 |
-
|
| 5493 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5494 |
|
| 5495 |
`is_placeholder` can be used to detect the standard placeholders `_1`,
|
| 5496 |
`_2`, and so on. `bind` uses `is_placeholder` to detect placeholders.
|
| 5497 |
-
Users may specialize this template to indicate a placeholder type.
|
| 5498 |
|
| 5499 |
-
|
| 5500 |
-
|
| 5501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5502 |
|
| 5503 |
-
####
|
| 5504 |
|
| 5505 |
In the text that follows, the following names have the following
|
| 5506 |
meanings:
|
| 5507 |
|
| 5508 |
-
- `FD` is the type `
|
| 5509 |
- `fd` is an lvalue of type `FD` constructed from `std::forward<F>(f)`,
|
| 5510 |
-
- `Ti` is the iᵗʰ type in the template parameter
|
| 5511 |
-
- `TiD` is the type `
|
| 5512 |
- `ti` is the iᵗʰ argument in the function parameter pack `bound_args`,
|
| 5513 |
- `tid` is an lvalue of type `TiD` constructed from
|
| 5514 |
`std::forward<Ti>(ti)`,
|
| 5515 |
- `Uj` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
|
| 5516 |
the forwarding call wrapper, and
|
|
@@ -5527,11 +6020,11 @@ template<class F, class... BoundArgs>
|
|
| 5527 |
expression for some values *w1, w2, ..., wN*, where
|
| 5528 |
`N == sizeof...(bound_args)`.
|
| 5529 |
|
| 5530 |
*Returns:* A forwarding call wrapper `g` with a weak result
|
| 5531 |
type ([[func.require]]). The effect of `g(u1, u2, ..., uM)` shall be
|
| 5532 |
-
*`INVOKE`*`(fd, v1, v2, ..., vN,
|
| 5533 |
where *`cv`* represents the *cv*-qualifiers of `g` and the values and
|
| 5534 |
types of the bound arguments `v1, v2, ..., vN` are determined as
|
| 5535 |
specified below. The copy constructor and move constructor of the
|
| 5536 |
forwarding call wrapper shall throw an exception if and only if the
|
| 5537 |
corresponding constructor of `FD` or of any of the types `TiD` throws an
|
|
@@ -5556,11 +6049,12 @@ template<class R, class F, class... BoundArgs>
|
|
| 5556 |
*`INVOKE`*`(fd, w1, w2, ..., wN)` shall be a valid expression for some
|
| 5557 |
values *w1, w2, ..., wN*, where `N == sizeof...(bound_args)`.
|
| 5558 |
|
| 5559 |
*Returns:* A forwarding call wrapper `g` with a nested type
|
| 5560 |
`result_type` defined as a synonym for `R`. The effect of
|
| 5561 |
-
`g(u1, u2, ..., uM)` shall be
|
|
|
|
| 5562 |
where the values and types of the bound arguments `v1, v2, ..., vN` are
|
| 5563 |
determined as specified below. The copy constructor and move constructor
|
| 5564 |
of the forwarding call wrapper shall throw an exception if and only if
|
| 5565 |
the corresponding constructor of `FD` or of any of the types `TiD`
|
| 5566 |
throws an exception.
|
|
@@ -5581,16 +6075,16 @@ from the call to `bind` and the *cv*-qualifiers *cv* of the call wrapper
|
|
| 5581 |
|
| 5582 |
- if `TiD` is `reference_wrapper<T>`, the argument is `tid.get()` and
|
| 5583 |
its type `Vi` is `T&`;
|
| 5584 |
- if the value of `is_bind_expression<TiD>::value` is `true`, the
|
| 5585 |
argument is `tid(std::forward<Uj>({}uj)...)` and its type `Vi` is
|
| 5586 |
-
`
|
| 5587 |
- if the value `j` of `is_placeholder<TiD>::value` is not zero, the
|
| 5588 |
argument is `std::forward<Uj>(uj)` and its type `Vi` is `Uj&&`;
|
| 5589 |
- otherwise, the value is `tid` and its type `Vi` is `TiD cv &`.
|
| 5590 |
|
| 5591 |
-
####
|
| 5592 |
|
| 5593 |
``` cpp
|
| 5594 |
namespace std {
|
| 5595 |
namespace placeholders {
|
| 5596 |
// M is the implementation-defined number of placeholders
|
|
@@ -5611,36 +6105,11 @@ whether placeholder types are `CopyAssignable`. `CopyAssignable`
|
|
| 5611 |
placeholders’ copy assignment operators shall not throw exceptions.
|
| 5612 |
|
| 5613 |
### Function template `mem_fn` <a id="func.memfn">[[func.memfn]]</a>
|
| 5614 |
|
| 5615 |
``` cpp
|
| 5616 |
-
template<class R, class T>
|
| 5617 |
-
unspecified mem_fn(R T::* pm);
|
| 5618 |
-
template<class R, class T, class... Args>
|
| 5619 |
-
unspecified mem_fn(R (T::* pm)(Args...));
|
| 5620 |
-
template<class R, class T, class... Args>
|
| 5621 |
-
unspecified mem_fn(R (T::* pm)(Args...) const);
|
| 5622 |
-
template<class R, class T, class... Args>
|
| 5623 |
-
unspecified mem_fn(R (T::* pm)(Args...) volatile);
|
| 5624 |
-
template<class R, class T, class... Args>
|
| 5625 |
-
unspecified mem_fn(R (T::* pm)(Args...) const volatile);
|
| 5626 |
-
template<class R, class T, class... Args>
|
| 5627 |
-
unspecified mem_fn(R (T::* pm)(Args...) &);
|
| 5628 |
-
template<class R, class T, class... Args>
|
| 5629 |
-
unspecified mem_fn(R (T::* pm)(Args...) const &);
|
| 5630 |
-
template<class R, class T, class... Args>
|
| 5631 |
-
unspecified mem_fn(R (T::* pm)(Args...) volatile &);
|
| 5632 |
-
template<class R, class T, class... Args>
|
| 5633 |
-
unspecified mem_fn(R (T::* pm)(Args...) const volatile &);
|
| 5634 |
-
template<class R, class T, class... Args>
|
| 5635 |
-
unspecified mem_fn(R (T::* pm)(Args...) &&);
|
| 5636 |
-
template<class R, class T, class... Args>
|
| 5637 |
-
unspecified mem_fn(R (T::* pm)(Args...) const &&);
|
| 5638 |
-
template<class R, class T, class... Args>
|
| 5639 |
-
unspecified mem_fn(R (T::* pm)(Args...) volatile &&);
|
| 5640 |
-
template<class R, class T, class... Args>
|
| 5641 |
-
unspecified mem_fn(R (T::* pm)(Args...) const volatile &&);
|
| 5642 |
```
|
| 5643 |
|
| 5644 |
*Returns:* A simple call wrapper ([[func.def]]) `fn` such that the
|
| 5645 |
expression `fn(t, a2, ..., aN)` is equivalent to
|
| 5646 |
*`INVOKE`*`(pm, t, a2, ..., aN)` ([[func.require]]). `fn` shall have a
|
|
@@ -5698,15 +6167,15 @@ namespace std {
|
|
| 5698 |
|
| 5699 |
template<class R, class... ArgTypes>
|
| 5700 |
class function<R(ArgTypes...)> {
|
| 5701 |
public:
|
| 5702 |
typedef R result_type;
|
| 5703 |
-
typedef T1 argument_type; //
|
| 5704 |
// the type in ArgTypes is T1
|
| 5705 |
-
typedef T1 first_argument_type; //
|
| 5706 |
// ArgTypes contains T1 and T2
|
| 5707 |
-
typedef T2 second_argument_type; //
|
| 5708 |
// ArgTypes contains T1 and T2
|
| 5709 |
|
| 5710 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 5711 |
function() noexcept;
|
| 5712 |
function(nullptr_t) noexcept;
|
|
@@ -5740,12 +6209,12 @@ namespace std {
|
|
| 5740 |
// [func.wrap.func.inv], function invocation:
|
| 5741 |
R operator()(ArgTypes...) const;
|
| 5742 |
|
| 5743 |
// [func.wrap.func.targ], function target access:
|
| 5744 |
const std::type_info& target_type() const noexcept;
|
| 5745 |
-
template
|
| 5746 |
-
template
|
| 5747 |
|
| 5748 |
};
|
| 5749 |
|
| 5750 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 5751 |
template <class R, class... ArgTypes>
|
|
@@ -5834,20 +6303,21 @@ state with an unspecified value.
|
|
| 5834 |
``` cpp
|
| 5835 |
template<class F> function(F f);
|
| 5836 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 5837 |
```
|
| 5838 |
|
| 5839 |
-
*Requires:* `F` shall be `CopyConstructible`.
|
| 5840 |
-
|
| 5841 |
-
|
| 5842 |
-
|
|
|
|
| 5843 |
|
| 5844 |
*Postconditions:* `!*this` if any of the following hold:
|
| 5845 |
|
| 5846 |
-
- `f` is a
|
| 5847 |
-
- `f` is a
|
| 5848 |
-
- `F` is an instance of the `function` class template, and `!f`
|
| 5849 |
|
| 5850 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 5851 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 5852 |
dynamically allocated memory for small callable objects, for example,
|
| 5853 |
where `f`’s target is an object holding only a pointer or reference to
|
|
@@ -5875,11 +6345,11 @@ function& operator=(function&& f);
|
|
| 5875 |
|
| 5876 |
``` cpp
|
| 5877 |
function& operator=(nullptr_t);
|
| 5878 |
```
|
| 5879 |
|
| 5880 |
-
*Effects:* If `*this !=
|
| 5881 |
|
| 5882 |
*Postconditions:* `!(*this)`.
|
| 5883 |
|
| 5884 |
*Returns:* `*this`
|
| 5885 |
|
|
@@ -5889,10 +6359,15 @@ template<class F> function& operator=(F&& f);
|
|
| 5889 |
|
| 5890 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 5891 |
|
| 5892 |
*Returns:* `*this`
|
| 5893 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5894 |
``` cpp
|
| 5895 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 5896 |
```
|
| 5897 |
|
| 5898 |
*Effects:* `function(f).swap(*this);`
|
|
@@ -5901,11 +6376,11 @@ template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
|
| 5901 |
|
| 5902 |
``` cpp
|
| 5903 |
~function();
|
| 5904 |
```
|
| 5905 |
|
| 5906 |
-
*Effects:* If `*this !=
|
| 5907 |
|
| 5908 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 5909 |
|
| 5910 |
``` cpp
|
| 5911 |
void swap(function& other) noexcept;
|
|
@@ -5952,18 +6427,18 @@ const std::type_info& target_type() const noexcept;
|
|
| 5952 |
|
| 5953 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 5954 |
`typeid(void)`.
|
| 5955 |
|
| 5956 |
``` cpp
|
| 5957 |
-
template<
|
| 5958 |
-
template<
|
| 5959 |
```
|
| 5960 |
|
| 5961 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 5962 |
for parameter types `ArgTypes` and return type `R`.
|
| 5963 |
|
| 5964 |
-
*Returns:* If `
|
| 5965 |
function target; otherwise a null pointer.
|
| 5966 |
|
| 5967 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 5968 |
|
| 5969 |
``` cpp
|
|
@@ -5996,11 +6471,12 @@ template<class R, class... ArgTypes>
|
|
| 5996 |
### Class template `hash` <a id="unord.hash">[[unord.hash]]</a>
|
| 5997 |
|
| 5998 |
The unordered associative containers defined in [[unord]] use
|
| 5999 |
specializations of the class template `hash` as the default hash
|
| 6000 |
function. For all object types `Key` for which there exists a
|
| 6001 |
-
specialization `hash<Key>`,
|
|
|
|
| 6002 |
|
| 6003 |
- satisfy the `Hash` requirements ([[hash.requirements]]), with `Key`
|
| 6004 |
as the function call argument type, the `DefaultConstructible`
|
| 6005 |
requirements (Table [[defaultconstructible]]), the `CopyAssignable`
|
| 6006 |
requirements (Table [[copyassignable]]),
|
|
@@ -6035,12 +6511,12 @@ template <> struct hash<float>;
|
|
| 6035 |
template <> struct hash<double>;
|
| 6036 |
template <> struct hash<long double>;
|
| 6037 |
template <class T> struct hash<T*>;
|
| 6038 |
```
|
| 6039 |
|
| 6040 |
-
|
| 6041 |
-
|
| 6042 |
|
| 6043 |
## Metaprogramming and type traits <a id="meta">[[meta]]</a>
|
| 6044 |
|
| 6045 |
This subclause describes components used by C++programs, particularly in
|
| 6046 |
templates, to support the widest possible range of types, optimise
|
|
@@ -6081,12 +6557,12 @@ shall not be hidden and shall be unambiguously available in the
|
|
| 6081 |
BinaryTypeTrait.
|
| 6082 |
|
| 6083 |
A *TransformationTrait* modifies a property of a type. It shall be a
|
| 6084 |
class template that takes one template type argument and, optionally,
|
| 6085 |
additional arguments that help define the modification. It shall define
|
| 6086 |
-
a nested type named `type`, which shall be a synonym
|
| 6087 |
-
type.
|
| 6088 |
|
| 6089 |
### Header `<type_traits>` synopsis <a id="meta.type.synop">[[meta.type.synop]]</a>
|
| 6090 |
|
| 6091 |
``` cpp
|
| 6092 |
namespace std {
|
|
@@ -6095,10 +6571,11 @@ namespace std {
|
|
| 6095 |
typedef integral_constant<bool, true> true_type;
|
| 6096 |
typedef integral_constant<bool, false> false_type;
|
| 6097 |
|
| 6098 |
// [meta.unary.cat], primary type categories:
|
| 6099 |
template <class T> struct is_void;
|
|
|
|
| 6100 |
template <class T> struct is_integral;
|
| 6101 |
template <class T> struct is_floating_point;
|
| 6102 |
template <class T> struct is_array;
|
| 6103 |
template <class T> struct is_pointer;
|
| 6104 |
template <class T> struct is_lvalue_reference;
|
|
@@ -6128,10 +6605,11 @@ namespace std {
|
|
| 6128 |
template <class T> struct is_pod;
|
| 6129 |
template <class T> struct is_literal_type;
|
| 6130 |
template <class T> struct is_empty;
|
| 6131 |
template <class T> struct is_polymorphic;
|
| 6132 |
template <class T> struct is_abstract;
|
|
|
|
| 6133 |
|
| 6134 |
template <class T> struct is_signed;
|
| 6135 |
template <class T> struct is_unsigned;
|
| 6136 |
|
| 6137 |
template <class T, class... Args> struct is_constructible;
|
|
@@ -6183,27 +6661,62 @@ namespace std {
|
|
| 6183 |
template <class T> struct remove_cv;
|
| 6184 |
template <class T> struct add_const;
|
| 6185 |
template <class T> struct add_volatile;
|
| 6186 |
template <class T> struct add_cv;
|
| 6187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6188 |
// [meta.trans.ref], reference modifications:
|
| 6189 |
template <class T> struct remove_reference;
|
| 6190 |
template <class T> struct add_lvalue_reference;
|
| 6191 |
template <class T> struct add_rvalue_reference;
|
| 6192 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6193 |
// [meta.trans.sign], sign modifications:
|
| 6194 |
template <class T> struct make_signed;
|
| 6195 |
template <class T> struct make_unsigned;
|
| 6196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6197 |
// [meta.trans.arr], array modifications:
|
| 6198 |
template <class T> struct remove_extent;
|
| 6199 |
template <class T> struct remove_all_extents;
|
| 6200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6201 |
// [meta.trans.ptr], pointer modifications:
|
| 6202 |
template <class T> struct remove_pointer;
|
| 6203 |
template <class T> struct add_pointer;
|
| 6204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6205 |
// [meta.trans.other], other transformations:
|
| 6206 |
template <std::size_t Len,
|
| 6207 |
std::size_t Align = default-alignment> // see [meta.trans.other]
|
| 6208 |
struct aligned_storage;
|
| 6209 |
template <std::size_t Len, class... Types> struct aligned_union;
|
|
@@ -6212,10 +6725,28 @@ namespace std {
|
|
| 6212 |
template <bool, class T, class F> struct conditional;
|
| 6213 |
template <class... T> struct common_type;
|
| 6214 |
template <class T> struct underlying_type;
|
| 6215 |
template <class> class result_of; // not defined
|
| 6216 |
template <class F, class... ArgTypes> class result_of<F(ArgTypes...)>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6217 |
} // namespace std
|
| 6218 |
```
|
| 6219 |
|
| 6220 |
The behavior of a program that adds specializations for any of the class
|
| 6221 |
templates defined in this subclause is undefined unless otherwise
|
|
@@ -6228,11 +6759,12 @@ namespace std {
|
|
| 6228 |
template <class T, T v>
|
| 6229 |
struct integral_constant {
|
| 6230 |
static constexpr T value = v;
|
| 6231 |
typedef T value_type;
|
| 6232 |
typedef integral_constant<T,v> type;
|
| 6233 |
-
constexpr operator value_type() { return value; }
|
|
|
|
| 6234 |
};
|
| 6235 |
typedef integral_constant<bool, true> true_type;
|
| 6236 |
typedef integral_constant<bool, false> false_type;
|
| 6237 |
}
|
| 6238 |
```
|
|
@@ -6291,21 +6823,34 @@ is_const<const int&>::value // false
|
|
| 6291 |
is_const<int[3]>::value // false
|
| 6292 |
is_const<const int[3]>::value // true
|
| 6293 |
```
|
| 6294 |
|
| 6295 |
``` cpp
|
| 6296 |
-
|
| 6297 |
-
|
| 6298 |
-
|
| 6299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6300 |
```
|
| 6301 |
|
| 6302 |
Given the following function prototype:
|
| 6303 |
|
| 6304 |
``` cpp
|
| 6305 |
template <class T>
|
| 6306 |
-
|
| 6307 |
```
|
| 6308 |
|
| 6309 |
the predicate condition for a template specialization
|
| 6310 |
`is_constructible<T, Args...>` shall be satisfied if and only if the
|
| 6311 |
following variable definition would be well-formed for some invented
|
|
@@ -6327,10 +6872,13 @@ the “immediate context” and can result in the program being ill-formed.
|
|
| 6327 |
### Type property queries <a id="meta.unary.prop.query">[[meta.unary.prop.query]]</a>
|
| 6328 |
|
| 6329 |
This sub-clause contains templates that may be used to query properties
|
| 6330 |
of types at compile time.
|
| 6331 |
|
|
|
|
|
|
|
|
|
|
| 6332 |
``` cpp
|
| 6333 |
// the following assertions hold:
|
| 6334 |
assert(rank<int>::value == 0);
|
| 6335 |
assert(rank<int[2]>::value == 1);
|
| 6336 |
assert(rank<int[][4]>::value == 2);
|
|
@@ -6375,11 +6923,11 @@ is_base_of<int, int>::value // false
|
|
| 6375 |
|
| 6376 |
Given the following function prototype:
|
| 6377 |
|
| 6378 |
``` cpp
|
| 6379 |
template <class T>
|
| 6380 |
-
|
| 6381 |
```
|
| 6382 |
|
| 6383 |
the predicate condition for a template specialization
|
| 6384 |
`is_convertible<From, To>` shall be satisfied if and only if the return
|
| 6385 |
expression in the following code would be well-formed, including any
|
|
@@ -6418,22 +6966,22 @@ Each of the templates in this subclause shall be a
|
|
| 6418 |
|
| 6419 |
#### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
|
| 6420 |
|
| 6421 |
``` cpp
|
| 6422 |
// the following assertions hold:
|
| 6423 |
-
assert((is_same<
|
| 6424 |
-
assert((is_same<
|
| 6425 |
-
assert((is_same<
|
| 6426 |
-
assert((is_same<
|
| 6427 |
```
|
| 6428 |
|
| 6429 |
``` cpp
|
| 6430 |
// the following assertions hold:
|
| 6431 |
-
assert((is_same<
|
| 6432 |
-
assert((is_same<
|
| 6433 |
-
assert((is_same<
|
| 6434 |
-
assert((is_same<
|
| 6435 |
```
|
| 6436 |
|
| 6437 |
#### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
|
| 6438 |
|
| 6439 |
#### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
|
|
@@ -6457,21 +7005,21 @@ The nested typedef `common_type::type` shall be defined as follows:
|
|
| 6457 |
``` cpp
|
| 6458 |
template <class ...T> struct common_type;
|
| 6459 |
|
| 6460 |
template <class T>
|
| 6461 |
struct common_type<T> {
|
| 6462 |
-
typedef T type;
|
| 6463 |
};
|
| 6464 |
|
| 6465 |
template <class T, class U>
|
| 6466 |
struct common_type<T, U> {
|
| 6467 |
-
typedef decltype(true ? declval<T>() : declval<U>()) type;
|
| 6468 |
};
|
| 6469 |
|
| 6470 |
template <class T, class U, class... V>
|
| 6471 |
struct common_type<T, U, V...> {
|
| 6472 |
-
typedef
|
| 6473 |
};
|
| 6474 |
```
|
| 6475 |
|
| 6476 |
Given these definitions:
|
| 6477 |
|
|
@@ -6491,16 +7039,16 @@ typedef char S::*PMD;
|
|
| 6491 |
```
|
| 6492 |
|
| 6493 |
the following assertions will hold:
|
| 6494 |
|
| 6495 |
``` cpp
|
| 6496 |
-
static_assert(is_same<
|
| 6497 |
-
static_assert(is_same<
|
| 6498 |
-
static_assert(is_same<
|
| 6499 |
-
static_assert(is_same<
|
| 6500 |
-
static_assert(is_same<
|
| 6501 |
-
static_assert(is_same<
|
| 6502 |
```
|
| 6503 |
|
| 6504 |
## Compile-time rational arithmetic <a id="ratio">[[ratio]]</a>
|
| 6505 |
|
| 6506 |
### In general <a id="ratio.general">[[ratio.general]]</a>
|
|
@@ -6508,13 +7056,14 @@ static_assert(is_same<result_of<PMD(const S*)>::type, const char&>::value, "Erro
|
|
| 6508 |
This subclause describes the ratio library. It provides a class template
|
| 6509 |
`ratio` which exactly represents any finite rational number with a
|
| 6510 |
numerator and denominator representable by compile-time constants of
|
| 6511 |
type `intmax_t`.
|
| 6512 |
|
| 6513 |
-
Throughout this subclause,
|
| 6514 |
-
|
| 6515 |
-
|
|
|
|
| 6516 |
|
| 6517 |
### Header `<ratio>` synopsis <a id="ratio.syn">[[ratio.syn]]</a>
|
| 6518 |
|
| 6519 |
``` cpp
|
| 6520 |
namespace std {
|
|
@@ -6534,43 +7083,43 @@ namespace std {
|
|
| 6534 |
template <class R1, class R2> struct ratio_less_equal;
|
| 6535 |
template <class R1, class R2> struct ratio_greater;
|
| 6536 |
template <class R1, class R2> struct ratio_greater_equal;
|
| 6537 |
|
| 6538 |
// [ratio.si], convenience SI typedefs
|
| 6539 |
-
typedef ratio<1,
|
| 6540 |
-
typedef ratio<1,
|
| 6541 |
-
typedef ratio<1,
|
| 6542 |
-
typedef ratio<1,
|
| 6543 |
-
typedef ratio<1,
|
| 6544 |
-
typedef ratio<1,
|
| 6545 |
-
typedef ratio<1,
|
| 6546 |
-
typedef ratio<1,
|
| 6547 |
typedef ratio<1, 100> centi;
|
| 6548 |
typedef ratio<1, 10> deci;
|
| 6549 |
typedef ratio< 10, 1> deca;
|
| 6550 |
typedef ratio< 100, 1> hecto;
|
| 6551 |
-
typedef ratio<
|
| 6552 |
-
typedef ratio<
|
| 6553 |
-
typedef ratio<
|
| 6554 |
-
typedef ratio<
|
| 6555 |
-
typedef ratio<
|
| 6556 |
-
typedef ratio<
|
| 6557 |
-
typedef ratio<
|
| 6558 |
-
typedef ratio<
|
| 6559 |
}
|
| 6560 |
```
|
| 6561 |
|
| 6562 |
### Class template `ratio` <a id="ratio.ratio">[[ratio.ratio]]</a>
|
| 6563 |
|
| 6564 |
``` cpp
|
| 6565 |
namespace std {
|
| 6566 |
template <intmax_t N, intmax_t D = 1>
|
| 6567 |
class ratio {
|
| 6568 |
public:
|
| 6569 |
-
typedef ratio<num, den> type;
|
| 6570 |
static constexpr intmax_t num;
|
| 6571 |
static constexpr intmax_t den;
|
|
|
|
| 6572 |
};
|
| 6573 |
}
|
| 6574 |
```
|
| 6575 |
|
| 6576 |
If the template argument `D` is zero or the absolute values of either of
|
|
@@ -6717,32 +7266,32 @@ namespace chrono {
|
|
| 6717 |
template <class Rep> struct treat_as_floating_point;
|
| 6718 |
template <class Rep> struct duration_values;
|
| 6719 |
|
| 6720 |
// [time.duration.nonmember], duration arithmetic
|
| 6721 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 6722 |
-
|
| 6723 |
constexpr operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 6724 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 6725 |
-
|
| 6726 |
constexpr operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 6727 |
template <class Rep1, class Period, class Rep2>
|
| 6728 |
-
duration<
|
| 6729 |
constexpr operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 6730 |
template <class Rep1, class Rep2, class Period>
|
| 6731 |
-
duration<
|
| 6732 |
constexpr operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 6733 |
template <class Rep1, class Period, class Rep2>
|
| 6734 |
-
duration<
|
| 6735 |
constexpr operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 6736 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 6737 |
-
|
| 6738 |
constexpr operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 6739 |
template <class Rep1, class Period, class Rep2>
|
| 6740 |
-
duration<
|
| 6741 |
constexpr operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 6742 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 6743 |
-
|
| 6744 |
constexpr operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 6745 |
|
| 6746 |
// [time.duration.comparisons], duration comparisons
|
| 6747 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 6748 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs,
|
|
@@ -6775,60 +7324,87 @@ typedef duration<signed integer type of at least 35 bits > seconds;
|
|
| 6775 |
typedef duration<signed integer type of at least 29 bits, ratio< 60>> minutes;
|
| 6776 |
typedef duration<signed integer type of at least 23 bits, ratio<3600>> hours;
|
| 6777 |
|
| 6778 |
// [time.point.nonmember], time_point arithmetic
|
| 6779 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 6780 |
-
time_point<Clock,
|
| 6781 |
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 6782 |
template <class Rep1, class Period1, class Clock, class Duration2>
|
| 6783 |
-
time_point<Clock,
|
| 6784 |
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 6785 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 6786 |
-
time_point<Clock,
|
| 6787 |
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 6788 |
template <class Clock, class Duration1, class Duration2>
|
| 6789 |
-
|
| 6790 |
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 6791 |
|
| 6792 |
// [time.point.comparisons] time_point comparisons
|
| 6793 |
template <class Clock, class Duration1, class Duration2>
|
| 6794 |
-
bool operator==(const time_point<Clock, Duration1>& lhs,
|
| 6795 |
const time_point<Clock, Duration2>& rhs);
|
| 6796 |
template <class Clock, class Duration1, class Duration2>
|
| 6797 |
-
bool operator!=(const time_point<Clock, Duration1>& lhs,
|
| 6798 |
const time_point<Clock, Duration2>& rhs);
|
| 6799 |
template <class Clock, class Duration1, class Duration2>
|
| 6800 |
-
bool operator< (const time_point<Clock, Duration1>& lhs,
|
| 6801 |
const time_point<Clock, Duration2>& rhs);
|
| 6802 |
template <class Clock, class Duration1, class Duration2>
|
| 6803 |
-
bool operator<=(const time_point<Clock, Duration1>& lhs,
|
| 6804 |
const time_point<Clock, Duration2>& rhs);
|
| 6805 |
template <class Clock, class Duration1, class Duration2>
|
| 6806 |
-
bool operator> (const time_point<Clock, Duration1>& lhs,
|
| 6807 |
const time_point<Clock, Duration2>& rhs);
|
| 6808 |
template <class Clock, class Duration1, class Duration2>
|
| 6809 |
-
bool operator>=(const time_point<Clock, Duration1>& lhs,
|
| 6810 |
const time_point<Clock, Duration2>& rhs);
|
| 6811 |
|
| 6812 |
// [time.point.cast], time_point_cast
|
| 6813 |
-
|
| 6814 |
template <class ToDuration, class Clock, class Duration>
|
| 6815 |
-
time_point<Clock, ToDuration>
|
|
|
|
| 6816 |
|
| 6817 |
// [time.clock], clocks
|
| 6818 |
class system_clock;
|
| 6819 |
class steady_clock;
|
| 6820 |
class high_resolution_clock;
|
| 6821 |
|
| 6822 |
} // namespace chrono
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6823 |
} // namespace std
|
| 6824 |
```
|
| 6825 |
|
| 6826 |
### Clock requirements <a id="time.clock.req">[[time.clock.req]]</a>
|
| 6827 |
|
| 6828 |
A clock is a bundle consisting of a `duration`, a `time_point`, and a
|
| 6829 |
-
function `now()` to get the current time_point. The origin of the
|
| 6830 |
clock’s `time_point` is referred to as the clock’s *epoch*. A clock
|
| 6831 |
shall meet the requirements in Table [[tab:time.clock]].
|
| 6832 |
|
| 6833 |
In Table [[tab:time.clock]] `C1` and `C2` denote clock types. `t1` and
|
| 6834 |
`t2` are values returned by `C1::now()` where the call returning `t1`
|
|
@@ -6853,12 +7429,12 @@ A type `TC` meets the `TrivialClock` requirements if:
|
|
| 6853 |
this means, in particular, that operations on these types will not
|
| 6854 |
throw exceptions.
|
| 6855 |
- lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
|
| 6856 |
are swappable ([[swappable.requirements]]),
|
| 6857 |
- the function `TC::now()` does not throw exceptions, and
|
| 6858 |
-
- the type `TC::time_point::clock` meets the TrivialClock
|
| 6859 |
-
recursively.
|
| 6860 |
|
| 6861 |
### Time-related traits <a id="time.traits">[[time.traits]]</a>
|
| 6862 |
|
| 6863 |
#### `treat_as_floating_point` <a id="time.traits.is_fp">[[time.traits.is_fp]]</a>
|
| 6864 |
|
|
@@ -6926,11 +7502,11 @@ The value returned shall compare greater than `zero()`.
|
|
| 6926 |
#### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
|
| 6927 |
|
| 6928 |
``` cpp
|
| 6929 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 6930 |
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
|
| 6931 |
-
typedef chrono::duration<
|
| 6932 |
};
|
| 6933 |
```
|
| 6934 |
|
| 6935 |
The `period` of the `duration` indicated by this specialization of
|
| 6936 |
`common_type` shall be the greatest common divisor of `Period1` and
|
|
@@ -6946,11 +7522,11 @@ this conversion with no truncation error, although floating-point
|
|
| 6946 |
durations may have round-off errors.
|
| 6947 |
|
| 6948 |
``` cpp
|
| 6949 |
template <class Clock, class Duration1, class Duration2>
|
| 6950 |
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
|
| 6951 |
-
typedef chrono::time_point<Clock,
|
| 6952 |
};
|
| 6953 |
```
|
| 6954 |
|
| 6955 |
The common type of two `time_point` types is a `time_point` with the
|
| 6956 |
same clock as the two types and the common type of their two
|
|
@@ -7021,10 +7597,15 @@ is ill-formed.
|
|
| 7021 |
*Remarks:* If `Period::num` is not positive, the program is ill-formed.
|
| 7022 |
|
| 7023 |
*Requires:* Members of `duration` shall not throw exceptions other than
|
| 7024 |
those thrown by the indicated operations on their representations.
|
| 7025 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7026 |
``` cpp
|
| 7027 |
duration<long, ratio<60>> d0; // holds a count of minutes using a long
|
| 7028 |
duration<long long, milli> d1; // holds a count of milliseconds using a long long
|
| 7029 |
duration<double, ratio<1, 30>> d2; // holds a count with a tick period of $\frac{1}{30}$ of a second
|
| 7030 |
// (30 Hz) using a double
|
|
@@ -7056,11 +7637,12 @@ duration<int, milli> d(3.5); // error
|
|
| 7056 |
template <class Rep2, class Period2>
|
| 7057 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 7058 |
```
|
| 7059 |
|
| 7060 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 7061 |
-
unless
|
|
|
|
| 7062 |
`ratio_divide<Period2, period>::den` is `1` and
|
| 7063 |
`treat_as_floating_point<Rep2>::value` is `false`. This requirement
|
| 7064 |
prevents implicit truncation error when converting between
|
| 7065 |
integral-based `duration` types. Such a construction could easily lead
|
| 7066 |
to confusion about the value of the `duration`.
|
|
@@ -7194,53 +7776,53 @@ static constexpr duration max();
|
|
| 7194 |
*Returns:* `duration(duration_values<rep>::max())`.
|
| 7195 |
|
| 7196 |
#### `duration` non-member arithmetic <a id="time.duration.nonmember">[[time.duration.nonmember]]</a>
|
| 7197 |
|
| 7198 |
In the function descriptions that follow, `CD` represents the return
|
| 7199 |
-
type of the function. `CR(A,B)` represents `
|
| 7200 |
|
| 7201 |
``` cpp
|
| 7202 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7203 |
-
constexpr
|
| 7204 |
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7205 |
```
|
| 7206 |
|
| 7207 |
*Returns:* CD(CD(lhs).count() + CD(rhs).count()).
|
| 7208 |
|
| 7209 |
``` cpp
|
| 7210 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7211 |
-
constexpr
|
| 7212 |
operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7213 |
```
|
| 7214 |
|
| 7215 |
*Returns:* CD(CD(lhs).count() - CD(rhs).count()).
|
| 7216 |
|
| 7217 |
``` cpp
|
| 7218 |
template <class Rep1, class Period, class Rep2>
|
| 7219 |
-
constexpr duration<
|
| 7220 |
operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7221 |
```
|
| 7222 |
|
| 7223 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7224 |
unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)`.
|
| 7225 |
|
| 7226 |
*Returns:* CD(CD(d).count() \* s).
|
| 7227 |
|
| 7228 |
``` cpp
|
| 7229 |
template <class Rep1, class Rep2, class Period>
|
| 7230 |
-
constexpr duration<
|
| 7231 |
operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 7232 |
```
|
| 7233 |
|
| 7234 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7235 |
unless `Rep1` is implicitly convertible to `CR(Rep1, Rep2)`.
|
| 7236 |
|
| 7237 |
*Returns:* `d * s`.
|
| 7238 |
|
| 7239 |
``` cpp
|
| 7240 |
template <class Rep1, class Period, class Rep2>
|
| 7241 |
-
constexpr duration<
|
| 7242 |
operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7243 |
```
|
| 7244 |
|
| 7245 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7246 |
unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
|
|
@@ -7248,19 +7830,19 @@ is not an instantiation of `duration`.
|
|
| 7248 |
|
| 7249 |
*Returns:* CD(CD(d).count() / s).
|
| 7250 |
|
| 7251 |
``` cpp
|
| 7252 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7253 |
-
constexpr
|
| 7254 |
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7255 |
```
|
| 7256 |
|
| 7257 |
*Returns:* `CD(lhs).count() / CD(rhs).count()`.
|
| 7258 |
|
| 7259 |
``` cpp
|
| 7260 |
template <class Rep1, class Period, class Rep2>
|
| 7261 |
-
constexpr duration<
|
| 7262 |
operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7263 |
```
|
| 7264 |
|
| 7265 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7266 |
unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
|
|
@@ -7268,20 +7850,20 @@ is not an instantiation of `duration`.
|
|
| 7268 |
|
| 7269 |
*Returns:* CD(CD(d).count() % s).
|
| 7270 |
|
| 7271 |
``` cpp
|
| 7272 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7273 |
-
constexpr
|
| 7274 |
operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7275 |
```
|
| 7276 |
|
| 7277 |
*Returns:* CD(CD(lhs).count() % CD(rhs).count()).
|
| 7278 |
|
| 7279 |
#### `duration` comparisons <a id="time.duration.comparisons">[[time.duration.comparisons]]</a>
|
| 7280 |
|
| 7281 |
In the function descriptions that follow, `CT` represents
|
| 7282 |
-
`
|
| 7283 |
arguments to the function.
|
| 7284 |
|
| 7285 |
``` cpp
|
| 7286 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7287 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
@@ -7363,10 +7945,81 @@ conversions are done with `static_cast`. It avoids multiplications and
|
|
| 7363 |
divisions when it is known at compile time that one or more arguments
|
| 7364 |
is 1. Intermediate computations are carried out in the widest
|
| 7365 |
representation and only converted to the destination representation at
|
| 7366 |
the final step.
|
| 7367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7368 |
### Class template `time_point` <a id="time.point">[[time.point]]</a>
|
| 7369 |
|
| 7370 |
``` cpp
|
| 7371 |
template <class Clock, class Duration = typename Clock::duration>
|
| 7372 |
class time_point {
|
|
@@ -7378,17 +8031,17 @@ public:
|
|
| 7378 |
private:
|
| 7379 |
duration d_; // exposition only
|
| 7380 |
|
| 7381 |
public:
|
| 7382 |
// [time.point.cons], construct:
|
| 7383 |
-
time_point(); // has value epoch
|
| 7384 |
-
explicit time_point(const duration& d); // same as time_point() + d
|
| 7385 |
template <class Duration2>
|
| 7386 |
-
|
| 7387 |
|
| 7388 |
// [time.point.observer], observer:
|
| 7389 |
-
duration time_since_epoch() const;
|
| 7390 |
|
| 7391 |
// [time.point.arithmetic], arithmetic:
|
| 7392 |
time_point& operator+=(const duration& d);
|
| 7393 |
time_point& operator-=(const duration& d);
|
| 7394 |
|
|
@@ -7404,27 +8057,27 @@ If `Duration` is not an instance of `duration`, the program is
|
|
| 7404 |
ill-formed.
|
| 7405 |
|
| 7406 |
#### `time_point` constructors <a id="time.point.cons">[[time.point.cons]]</a>
|
| 7407 |
|
| 7408 |
``` cpp
|
| 7409 |
-
time_point();
|
| 7410 |
```
|
| 7411 |
|
| 7412 |
*Effects:* Constructs an object of type `time_point`, initializing `d_`
|
| 7413 |
with `duration::zero()`. Such a `time_point` object represents the
|
| 7414 |
epoch.
|
| 7415 |
|
| 7416 |
``` cpp
|
| 7417 |
-
time_point(const duration& d);
|
| 7418 |
```
|
| 7419 |
|
| 7420 |
*Effects:* Constructs an object of type `time_point`, initializing `d_`
|
| 7421 |
with `d`. Such a `time_point` object represents the epoch `+ d`.
|
| 7422 |
|
| 7423 |
``` cpp
|
| 7424 |
template <class Duration2>
|
| 7425 |
-
time_point(const time_point<clock, Duration2>& t);
|
| 7426 |
```
|
| 7427 |
|
| 7428 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 7429 |
unless `Duration2` is implicitly convertible to `duration`.
|
| 7430 |
|
|
@@ -7432,11 +8085,11 @@ unless `Duration2` is implicitly convertible to `duration`.
|
|
| 7432 |
with `t.time_since_epoch()`.
|
| 7433 |
|
| 7434 |
#### `time_point` observer <a id="time.point.observer">[[time.point.observer]]</a>
|
| 7435 |
|
| 7436 |
``` cpp
|
| 7437 |
-
duration time_since_epoch() const;
|
| 7438 |
```
|
| 7439 |
|
| 7440 |
*Returns:* `d_`.
|
| 7441 |
|
| 7442 |
#### `time_point` arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
|
|
@@ -7473,89 +8126,91 @@ static constexpr time_point max();
|
|
| 7473 |
|
| 7474 |
#### `time_point` non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
|
| 7475 |
|
| 7476 |
``` cpp
|
| 7477 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 7478 |
-
time_point<Clock,
|
| 7479 |
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7480 |
```
|
| 7481 |
|
| 7482 |
-
*Returns:* `CT(lhs) +
|
|
|
|
| 7483 |
|
| 7484 |
``` cpp
|
| 7485 |
template <class Rep1, class Period1, class Clock, class Duration2>
|
| 7486 |
-
time_point<Clock,
|
| 7487 |
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7488 |
```
|
| 7489 |
|
| 7490 |
*Returns:* `rhs + lhs`.
|
| 7491 |
|
| 7492 |
``` cpp
|
| 7493 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 7494 |
-
time_point<Clock,
|
| 7495 |
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7496 |
```
|
| 7497 |
|
| 7498 |
*Returns:* `lhs + (-rhs)`.
|
| 7499 |
|
| 7500 |
``` cpp
|
| 7501 |
template <class Clock, class Duration1, class Duration2>
|
| 7502 |
-
|
| 7503 |
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7504 |
```
|
| 7505 |
|
| 7506 |
*Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
|
| 7507 |
|
| 7508 |
#### `time_point` comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
|
| 7509 |
|
| 7510 |
``` cpp
|
| 7511 |
template <class Clock, class Duration1, class Duration2>
|
| 7512 |
-
bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7513 |
```
|
| 7514 |
|
| 7515 |
*Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
|
| 7516 |
|
| 7517 |
``` cpp
|
| 7518 |
template <class Clock, class Duration1, class Duration2>
|
| 7519 |
-
bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7520 |
```
|
| 7521 |
|
| 7522 |
*Returns:* `!(lhs == rhs)`.
|
| 7523 |
|
| 7524 |
``` cpp
|
| 7525 |
template <class Clock, class Duration1, class Duration2>
|
| 7526 |
-
bool operator<(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7527 |
```
|
| 7528 |
|
| 7529 |
*Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
|
| 7530 |
|
| 7531 |
``` cpp
|
| 7532 |
template <class Clock, class Duration1, class Duration2>
|
| 7533 |
-
bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7534 |
```
|
| 7535 |
|
| 7536 |
*Returns:* `!(rhs < lhs)`.
|
| 7537 |
|
| 7538 |
``` cpp
|
| 7539 |
template <class Clock, class Duration1, class Duration2>
|
| 7540 |
-
bool operator>(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7541 |
```
|
| 7542 |
|
| 7543 |
*Returns:* `rhs < lhs`.
|
| 7544 |
|
| 7545 |
``` cpp
|
| 7546 |
template <class Clock, class Duration1, class Duration2>
|
| 7547 |
-
bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7548 |
```
|
| 7549 |
|
| 7550 |
*Returns:* `!(lhs < rhs)`.
|
| 7551 |
|
| 7552 |
#### `time_point_cast` <a id="time.point.cast">[[time.point.cast]]</a>
|
| 7553 |
|
| 7554 |
``` cpp
|
| 7555 |
template <class ToDuration, class Clock, class Duration>
|
| 7556 |
-
time_point<Clock, ToDuration>
|
|
|
|
| 7557 |
```
|
| 7558 |
|
| 7559 |
*Remarks:* This function shall not participate in overload resolution
|
| 7560 |
unless `ToDuration` is an instantiation of `duration`.
|
| 7561 |
|
|
@@ -7577,11 +8232,11 @@ class system_clock {
|
|
| 7577 |
public:
|
| 7578 |
typedef see below rep;
|
| 7579 |
typedef ratio<unspecified, unspecified> period;
|
| 7580 |
typedef chrono::duration<rep, period> duration;
|
| 7581 |
typedef chrono::time_point<system_clock> time_point;
|
| 7582 |
-
static
|
| 7583 |
|
| 7584 |
static time_point now() noexcept;
|
| 7585 |
|
| 7586 |
// Map to C API
|
| 7587 |
static time_t to_time_t (const time_point& t) noexcept;
|
|
@@ -7627,11 +8282,11 @@ class steady_clock {
|
|
| 7627 |
public:
|
| 7628 |
typedef unspecified rep;
|
| 7629 |
typedef ratio<unspecified, unspecified> period;
|
| 7630 |
typedef chrono::duration<rep, period> duration;
|
| 7631 |
typedef chrono::time_point<unspecified, duration> time_point;
|
| 7632 |
-
static
|
| 7633 |
|
| 7634 |
static time_point now() noexcept;
|
| 7635 |
};
|
| 7636 |
```
|
| 7637 |
|
|
@@ -7646,11 +8301,11 @@ class high_resolution_clock {
|
|
| 7646 |
public:
|
| 7647 |
typedef unspecified rep;
|
| 7648 |
typedef ratio<unspecified, unspecified> period;
|
| 7649 |
typedef chrono::duration<rep, period> duration;
|
| 7650 |
typedef chrono::time_point<unspecified, duration> time_point;
|
| 7651 |
-
static
|
| 7652 |
|
| 7653 |
static time_point now() noexcept;
|
| 7654 |
};
|
| 7655 |
```
|
| 7656 |
|
|
@@ -7757,11 +8412,11 @@ namespace std {
|
|
| 7757 |
pointer allocate(size_type n, const_void_pointer hint);
|
| 7758 |
void deallocate(pointer p, size_type n);
|
| 7759 |
size_type max_size() const;
|
| 7760 |
|
| 7761 |
template <class T, class... Args>
|
| 7762 |
-
void construct(T* p, Args&& args);
|
| 7763 |
template <class T1, class T2, class... Args1, class... Args2>
|
| 7764 |
void construct(pair<T1, T2>* p, piecewise_construct_t,
|
| 7765 |
tuple<Args1...> x, tuple<Args2...> y);
|
| 7766 |
template <class T1, class T2>
|
| 7767 |
void construct(pair<T1, T2>* p);
|
|
@@ -7828,11 +8483,11 @@ any `A` in the set of `OuterAlloc` and `InnerAllocs...`; otherwise,
|
|
| 7828 |
|
| 7829 |
``` cpp
|
| 7830 |
scoped_allocator_adaptor();
|
| 7831 |
```
|
| 7832 |
|
| 7833 |
-
*Effects:* value-initializes the OuterAlloc base class and the `inner`
|
| 7834 |
allocator object.
|
| 7835 |
|
| 7836 |
``` cpp
|
| 7837 |
template <class OuterA2>
|
| 7838 |
scoped_allocator_adaptor(OuterA2&& outerAlloc,
|
|
@@ -7985,16 +8640,16 @@ following rules:
|
|
| 7985 |
`x`.
|
| 7986 |
- Otherwise, if `uses_allocator<T1, inner_allocator_type>::value` is
|
| 7987 |
`true` and
|
| 7988 |
`is_constructible<T1, allocator_arg_t, inner_allocator_type, Args1...>::value`
|
| 7989 |
is `true`, then `xprime` is
|
| 7990 |
-
`tuple_cat(tuple<allocator_arg_t, inner_allocator_type&>( allocator_arg,
|
| 7991 |
- Otherwise, if `uses_allocator<T1, inner_allocator_type>::value` is
|
| 7992 |
`true` and
|
| 7993 |
`is_constructible<T1, Args1..., inner_allocator_type>::value` is
|
| 7994 |
`true`, then `xprime` is
|
| 7995 |
-
`tuple_cat(x, tuple<inner_allocator_type&>(
|
| 7996 |
- Otherwise, the program is ill-formed.
|
| 7997 |
|
| 7998 |
and constructs a `tuple` object `yprime` from `y` by the following
|
| 7999 |
rules:
|
| 8000 |
|
|
@@ -8003,52 +8658,52 @@ rules:
|
|
| 8003 |
`y`.
|
| 8004 |
- Otherwise, if `uses_allocator<T2, inner_allocator_type>::value` is
|
| 8005 |
`true` and
|
| 8006 |
`is_constructible<T2, allocator_arg_t, inner_allocator_type, Args2...>::value`
|
| 8007 |
is `true`, then `yprime` is
|
| 8008 |
-
`tuple_cat(tuple<allocator_arg_t, inner_allocator_type&>( allocator_arg,
|
| 8009 |
- Otherwise, if `uses_allocator<T2, inner_allocator_type>::value` is
|
| 8010 |
`true` and
|
| 8011 |
`is_constructible<T2, Args2..., inner_allocator_type>::value` is
|
| 8012 |
`true`, then `yprime` is
|
| 8013 |
-
`tuple_cat(y, tuple<inner_allocator_type&>(
|
| 8014 |
- Otherwise, the program is ill-formed.
|
| 8015 |
|
| 8016 |
then calls
|
| 8017 |
*`OUTERMOST_ALLOC_TRAITS`*`(*this)::construct(`*`OUTERMOST`*`(*this), p,`
|
| 8018 |
-
`piecewise_construct, xprime, yprime)`.
|
| 8019 |
|
| 8020 |
``` cpp
|
| 8021 |
template <class T1, class T2>
|
| 8022 |
void construct(pair<T1, T2>* p);
|
| 8023 |
```
|
| 8024 |
|
| 8025 |
-
*Effects:*
|
| 8026 |
`this->construct(p, piecewise_construct, tuple<>(), tuple<>())`.
|
| 8027 |
|
| 8028 |
``` cpp
|
| 8029 |
template <class T1, class T2, class U, class V>
|
| 8030 |
void construct(pair<T1, T2>* p, U&& x, V&& y);
|
| 8031 |
```
|
| 8032 |
|
| 8033 |
-
*Effects:*
|
| 8034 |
`this->construct(p, piecewise_construct, forward_as_tuple(std::forward<U>(x)), forward_as_tuple(std::forward<V>(y)))`.
|
| 8035 |
|
| 8036 |
``` cpp
|
| 8037 |
template <class T1, class T2, class U, class V>
|
| 8038 |
void construct(pair<T1, T2>* p, const pair<U, V>& x);
|
| 8039 |
```
|
| 8040 |
|
| 8041 |
-
*Effects:*
|
| 8042 |
`this->construct(p, piecewise_construct, forward_as_tuple(x.first), forward_as_tuple(x.second))`.
|
| 8043 |
|
| 8044 |
``` cpp
|
| 8045 |
template <class T1, class T2, class U, class V>
|
| 8046 |
void construct(pair<T1, T2>* p, pair<U, V>&& x);
|
| 8047 |
```
|
| 8048 |
|
| 8049 |
-
*Effects:*
|
| 8050 |
`this->construct(p, piecewise_construct, forward_as_tuple(std::forward<U>(x.first)), forward_as_tuple(std::forward<V>(x.second)))`.
|
| 8051 |
|
| 8052 |
``` cpp
|
| 8053 |
template <class T>
|
| 8054 |
void destroy(T* p);
|
|
@@ -8110,12 +8765,12 @@ namespace std {
|
|
| 8110 |
bool operator!=(const type_index& rhs) const noexcept;
|
| 8111 |
bool operator< (const type_index& rhs) const noexcept;
|
| 8112 |
bool operator<= (const type_index& rhs) const noexcept;
|
| 8113 |
bool operator> (const type_index& rhs) const noexcept;
|
| 8114 |
bool operator>= (const type_index& rhs) const noexcept;
|
| 8115 |
-
size_t hash_code() const;
|
| 8116 |
-
const char* name() const;
|
| 8117 |
private:
|
| 8118 |
const type_info* target; // exposition only
|
| 8119 |
// Note that the use of a pointer here, rather than a reference,
|
| 8120 |
// means that the default copy/move constructor and assignment
|
| 8121 |
// operators will be provided and work as expected.
|
|
@@ -8171,29 +8826,29 @@ bool operator>=(const type_index& rhs) const noexcept;
|
|
| 8171 |
```
|
| 8172 |
|
| 8173 |
*Returns:* `!target->before(*rhs.target)`
|
| 8174 |
|
| 8175 |
``` cpp
|
| 8176 |
-
size_t hash_code() const;
|
| 8177 |
```
|
| 8178 |
|
| 8179 |
*Returns:* `target->hash_code()`
|
| 8180 |
|
| 8181 |
``` cpp
|
| 8182 |
-
const char* name() const;
|
| 8183 |
```
|
| 8184 |
|
| 8185 |
*Returns:* `target->name()`
|
| 8186 |
|
| 8187 |
### Hash support <a id="type.index.hash">[[type.index.hash]]</a>
|
| 8188 |
|
| 8189 |
``` cpp
|
| 8190 |
template <> struct hash<type_index>;
|
| 8191 |
```
|
| 8192 |
|
| 8193 |
-
|
| 8194 |
-
|
| 8195 |
`type_index`, `hash<type_index>()(index)` shall evaluate to the same
|
| 8196 |
result as `index.hash_code()`.
|
| 8197 |
|
| 8198 |
<!-- Link reference definitions -->
|
| 8199 |
[alg.sorting]: algorithms.md#alg.sorting
|
|
@@ -8224,18 +8879,18 @@ result as `index.hash_code()`.
|
|
| 8224 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 8225 |
[basic.life]: basic.md#basic.life
|
| 8226 |
[basic.stc.dynamic.safety]: basic.md#basic.stc.dynamic.safety
|
| 8227 |
[basic.type.qualifier]: basic.md#basic.type.qualifier
|
| 8228 |
[basic.types]: basic.md#basic.types
|
| 8229 |
-
[bind]: #bind
|
| 8230 |
[bitset.cons]: #bitset.cons
|
| 8231 |
[bitset.hash]: #bitset.hash
|
| 8232 |
[bitset.members]: #bitset.members
|
| 8233 |
[bitset.operators]: #bitset.operators
|
| 8234 |
[bitwise.operations]: #bitwise.operations
|
| 8235 |
[c.malloc]: #c.malloc
|
| 8236 |
[c.strings]: strings.md#c.strings
|
|
|
|
| 8237 |
[class.abstract]: class.md#class.abstract
|
| 8238 |
[class.derived]: class.md#class.derived
|
| 8239 |
[class.dtor]: special.md#class.dtor
|
| 8240 |
[class.virtual]: class.md#class.virtual
|
| 8241 |
[comparisons]: #comparisons
|
|
@@ -8271,10 +8926,11 @@ result as `index.hash_code()`.
|
|
| 8271 |
[forward]: #forward
|
| 8272 |
[forward.iterators]: iterators.md#forward.iterators
|
| 8273 |
[func.bind]: #func.bind
|
| 8274 |
[func.bind.bind]: #func.bind.bind
|
| 8275 |
[func.bind.isbind]: #func.bind.isbind
|
|
|
|
| 8276 |
[func.bind.place]: #func.bind.place
|
| 8277 |
[func.def]: #func.def
|
| 8278 |
[func.memfn]: #func.memfn
|
| 8279 |
[func.require]: #func.require
|
| 8280 |
[func.wrap]: #func.wrap
|
|
@@ -8290,10 +8946,14 @@ result as `index.hash_code()`.
|
|
| 8290 |
[func.wrap.func.targ]: #func.wrap.func.targ
|
| 8291 |
[function.objects]: #function.objects
|
| 8292 |
[hash.requirements]: library.md#hash.requirements
|
| 8293 |
[input.iterators]: iterators.md#input.iterators
|
| 8294 |
[intro.multithread]: intro.md#intro.multithread
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8295 |
[invalid.argument]: diagnostics.md#invalid.argument
|
| 8296 |
[iostate.flags]: input.md#iostate.flags
|
| 8297 |
[istream.formatted]: input.md#istream.formatted
|
| 8298 |
[lessthancomparable]: #lessthancomparable
|
| 8299 |
[logical.operations]: #logical.operations
|
|
@@ -8379,10 +9039,11 @@ result as `index.hash_code()`.
|
|
| 8379 |
[time.duration]: #time.duration
|
| 8380 |
[time.duration.arithmetic]: #time.duration.arithmetic
|
| 8381 |
[time.duration.cast]: #time.duration.cast
|
| 8382 |
[time.duration.comparisons]: #time.duration.comparisons
|
| 8383 |
[time.duration.cons]: #time.duration.cons
|
|
|
|
| 8384 |
[time.duration.nonmember]: #time.duration.nonmember
|
| 8385 |
[time.duration.observer]: #time.duration.observer
|
| 8386 |
[time.duration.special]: #time.duration.special
|
| 8387 |
[time.general]: #time.general
|
| 8388 |
[time.point]: #time.point
|
|
@@ -8417,10 +9078,11 @@ result as `index.hash_code()`.
|
|
| 8417 |
[type.index.synopsis]: #type.index.synopsis
|
| 8418 |
[uninitialized.copy]: #uninitialized.copy
|
| 8419 |
[uninitialized.fill]: #uninitialized.fill
|
| 8420 |
[uninitialized.fill.n]: #uninitialized.fill.n
|
| 8421 |
[unique.ptr]: #unique.ptr
|
|
|
|
| 8422 |
[unique.ptr.dltr]: #unique.ptr.dltr
|
| 8423 |
[unique.ptr.dltr.dflt]: #unique.ptr.dltr.dflt
|
| 8424 |
[unique.ptr.dltr.dflt1]: #unique.ptr.dltr.dflt1
|
| 8425 |
[unique.ptr.dltr.general]: #unique.ptr.dltr.general
|
| 8426 |
[unique.ptr.runtime]: #unique.ptr.runtime
|
|
@@ -8463,10 +9125,11 @@ result as `index.hash_code()`.
|
|
| 8463 |
[util.smartptr.weak.spec]: #util.smartptr.weak.spec
|
| 8464 |
[util.smartptr.weakptr]: #util.smartptr.weakptr
|
| 8465 |
[utilities]: #utilities
|
| 8466 |
[utilities.general]: #utilities.general
|
| 8467 |
[utility]: #utility
|
|
|
|
| 8468 |
[utility.swap]: #utility.swap
|
| 8469 |
|
| 8470 |
[^1]: `pointer_safety::preferred` might be returned to indicate that a
|
| 8471 |
leak detector is running so that the program can avoid spurious leak
|
| 8472 |
reports.
|
|
|
|
| 12 |
| Subclause | | Header |
|
| 13 |
| --------------------- | -------------------------------- | -------------------- |
|
| 14 |
| [[utility]] | Utility components | `<utility>` |
|
| 15 |
| [[pairs]] | Pairs | `<utility>` |
|
| 16 |
| [[tuple]] | Tuples | `<tuple>` |
|
| 17 |
+
| [[intseq]] | Compile-time integer sequences | `<utility>` |
|
| 18 |
| [[template.bitset]] | Fixed-size sequences of bits | `<bitset>` |
|
| 19 |
| | | `<memory>` |
|
| 20 |
| [[memory]] | Memory | `<cstdlib>` |
|
| 21 |
| | | `<cstring>` |
|
| 22 |
| [[smartptr]] | Smart pointers | `<memory>` |
|
|
|
|
| 54 |
|
| 55 |
// [utility.swap], swap:
|
| 56 |
template<class T> void swap(T& a, T& b) noexcept(see below);
|
| 57 |
template <class T, size_t N> void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b)));
|
| 58 |
|
| 59 |
+
// [utility.exchange], exchange:
|
| 60 |
+
template <class T, class U=T> T exchange(T& obj, U&& new_val);
|
| 61 |
+
|
| 62 |
// [forward], forward/move:
|
| 63 |
+
template <class T>
|
| 64 |
+
constexpr T&& forward(remove_reference_t<T>& t) noexcept;
|
| 65 |
+
template <class T>
|
| 66 |
+
constexpr T&& forward(remove_reference_t<T>&& t) noexcept;
|
| 67 |
+
template <class T>
|
| 68 |
+
constexpr remove_reference_t<T>&& move(T&&) noexcept;
|
| 69 |
+
template <class T>
|
| 70 |
+
constexpr conditional_t<
|
| 71 |
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
|
| 72 |
+
const T&, T&&> move_if_noexcept(T& x) noexcept;
|
| 73 |
|
| 74 |
// [declval], declval:
|
| 75 |
template <class T>
|
| 76 |
+
add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand
|
| 77 |
|
| 78 |
// [pairs], pairs:
|
| 79 |
template <class T1, class T2> struct pair;
|
| 80 |
|
| 81 |
// [pairs.spec], pair specialized algorithms:
|
| 82 |
template <class T1, class T2>
|
| 83 |
+
constexpr bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 84 |
template <class T1, class T2>
|
| 85 |
+
constexpr bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
|
| 86 |
template <class T1, class T2>
|
| 87 |
+
constexpr bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 88 |
template <class T1, class T2>
|
| 89 |
+
constexpr bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
|
| 90 |
template <class T1, class T2>
|
| 91 |
+
constexpr bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 92 |
template <class T1, class T2>
|
| 93 |
+
constexpr bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
|
| 94 |
template <class T1, class T2>
|
| 95 |
void swap(pair<T1,T2>& x, pair<T1,T2>& y) noexcept(noexcept(x.swap(y)));
|
| 96 |
template <class T1, class T2>
|
| 97 |
+
constexpr see below make_pair(T1&&, T2&&);
|
| 98 |
|
| 99 |
// [pair.astuple], tuple-like access to pair:
|
| 100 |
template <class T> class tuple_size;
|
| 101 |
template <size_t I, class T> class tuple_element;
|
| 102 |
|
| 103 |
+
template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
|
| 104 |
+
template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
|
| 105 |
+
template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;
|
| 106 |
|
| 107 |
template<size_t I, class T1, class T2>
|
| 108 |
+
constexpr tuple_element_t<I, pair<T1, T2>>&
|
| 109 |
+
get(pair<T1, T2>&) noexcept;
|
| 110 |
template<size_t I, class T1, class T2>
|
| 111 |
+
constexpr tuple_element_t<I, pair<T1, T2>>&&
|
| 112 |
+
get(pair<T1, T2>&&) noexcept;
|
| 113 |
template<size_t I, class T1, class T2>
|
| 114 |
+
constexpr const tuple_element_t<I, pair<T1, T2>>&
|
| 115 |
+
get(const pair<T1, T2>&) noexcept;
|
| 116 |
+
template <class T, class U>
|
| 117 |
+
constexpr T& get(pair<T, U>& p) noexcept;
|
| 118 |
+
template <class T, class U>
|
| 119 |
+
constexpr const T& get(const pair<T, U>& p) noexcept;
|
| 120 |
+
template <class T, class U>
|
| 121 |
+
constexpr T&& get(pair<T, U>&& p) noexcept;
|
| 122 |
+
template <class T, class U>
|
| 123 |
+
constexpr T& get(pair<U, T>& p) noexcept;
|
| 124 |
+
template <class T, class U>
|
| 125 |
+
constexpr const T& get(const pair<U, T>& p) noexcept;
|
| 126 |
+
template <class T, class U>
|
| 127 |
+
constexpr T&& get(pair<U, T>&& p) noexcept;
|
| 128 |
|
| 129 |
// [pair.piecewise], pair piecewise construction
|
| 130 |
struct piecewise_construct_t { };
|
| 131 |
+
constexpr piecewise_construct_t piecewise_construct{};
|
| 132 |
template <class... Types> class tuple; // defined in <tuple>
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
// [intseq], Compile-time integer sequences
|
| 136 |
+
template<class T, T...> struct integer_sequence;
|
| 137 |
+
template<size_t... I>
|
| 138 |
+
using index_sequence = integer_sequence<size_t, I...>;
|
| 139 |
+
|
| 140 |
+
template<class T, T N>
|
| 141 |
+
using make_integer_sequence = integer_sequence<T, see below>;
|
| 142 |
+
template<size_t N>
|
| 143 |
+
using make_index_sequence = make_integer_sequence<size_t, N>;
|
| 144 |
+
|
| 145 |
+
template<class... T>
|
| 146 |
+
using index_sequence_for = make_index_sequence<sizeof...(T)>;
|
| 147 |
}
|
| 148 |
```
|
| 149 |
|
| 150 |
### Operators <a id="operators">[[operators]]</a>
|
| 151 |
|
|
|
|
| 221 |
*Requires:* `a[i]` shall be swappable with ([[swappable.requirements]])
|
| 222 |
`b[i]` for all `i` in the range \[`0`, `N`).
|
| 223 |
|
| 224 |
*Effects:* `swap_ranges(a, a + N, b)`
|
| 225 |
|
| 226 |
+
### exchange <a id="utility.exchange">[[utility.exchange]]</a>
|
| 227 |
+
|
| 228 |
+
``` cpp
|
| 229 |
+
template <class T, class U=T> T exchange(T& obj, U&& new_val);
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
*Effects:* Equivalent to:
|
| 233 |
+
|
| 234 |
+
``` cpp
|
| 235 |
+
T old_val = std::move(obj);
|
| 236 |
+
obj = std::forward<U>(new_val);
|
| 237 |
+
return old_val;
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
### forward/move helpers <a id="forward">[[forward]]</a>
|
| 241 |
|
| 242 |
The library provides templated helper functions to simplify applying
|
| 243 |
move semantics to an lvalue and to simplify the implementation of
|
| 244 |
forwarding functions.
|
| 245 |
|
| 246 |
``` cpp
|
| 247 |
+
template <class T> constexpr T&& forward(remove_reference_t<T>& t) noexcept;
|
| 248 |
+
template <class T> constexpr T&& forward(remove_reference_t<T>&& t) noexcept;
|
| 249 |
```
|
| 250 |
|
| 251 |
*Returns:* `static_cast<T&&>(t)`.
|
| 252 |
|
| 253 |
+
If the second form is instantiated with an lvalue reference type, the
|
| 254 |
program is ill-formed.
|
| 255 |
|
| 256 |
``` cpp
|
| 257 |
template <class T, class A1, class A2>
|
| 258 |
shared_ptr<T> factory(A1&& a1, A2&& a2) {
|
|
|
|
| 275 |
`factory`, `A1` is deduced as `int&`, so `i` is forwarded to `A`’s
|
| 276 |
constructor as an lvalue. In both cases, `A2` is deduced as `double`, so
|
| 277 |
1.414 is forwarded to `A`’s constructor as an rvalue.
|
| 278 |
|
| 279 |
``` cpp
|
| 280 |
+
template <class T> constexpr remove_reference_t<T>&& move(T&& t) noexcept;
|
| 281 |
```
|
| 282 |
|
| 283 |
+
*Returns:* `static_cast<remove_reference_t<T>&&>(t)`.
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
template <class T, class A1>
|
| 287 |
shared_ptr<T> factory(A1&& a1) {
|
| 288 |
return shared_ptr<T>(new T(std::forward<A1>(a1)));
|
|
|
|
| 307 |
`factory`, because of the call `std::move(a)`, `A1` is deduced as `A`,
|
| 308 |
so `a` is forwarded as an rvalue. This binds to the constructor
|
| 309 |
`A(A&&)`, which moves the value from `a`.
|
| 310 |
|
| 311 |
``` cpp
|
| 312 |
+
template <class T> constexpr conditional_t<
|
| 313 |
!is_nothrow_move_constructible<T>::value && is_copy_constructible<T>::value,
|
| 314 |
+
const T&, T&&> move_if_noexcept(T& x) noexcept;
|
| 315 |
```
|
| 316 |
|
| 317 |
*Returns:* `std::move(x)`
|
| 318 |
|
| 319 |
### Function template `declval` <a id="declval">[[declval]]</a>
|
|
|
|
| 322 |
definition of expressions which occur as unevaluated operands (Clause
|
| 323 |
[[expr]]).
|
| 324 |
|
| 325 |
``` cpp
|
| 326 |
template <class T>
|
| 327 |
+
add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand
|
| 328 |
```
|
| 329 |
|
| 330 |
*Remarks:* If this function is odr-used ([[basic.def.odr]]), the
|
| 331 |
program is ill-formed.
|
| 332 |
|
|
|
|
| 367 |
T1 first;
|
| 368 |
T2 second;
|
| 369 |
pair(const pair&) = default;
|
| 370 |
pair(pair&&) = default;
|
| 371 |
constexpr pair();
|
| 372 |
+
constexpr pair(const T1& x, const T2& y);
|
| 373 |
+
template<class U, class V> constexpr pair(U&& x, V&& y);
|
| 374 |
+
template<class U, class V> constexpr pair(const pair<U, V>& p);
|
| 375 |
+
template<class U, class V> constexpr pair(pair<U, V>&& p);
|
| 376 |
template <class... Args1, class... Args2>
|
| 377 |
pair(piecewise_construct_t,
|
| 378 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 379 |
|
| 380 |
pair& operator=(const pair& p);
|
|
|
|
| 385 |
void swap(pair& p) noexcept(see below);
|
| 386 |
};
|
| 387 |
}
|
| 388 |
```
|
| 389 |
|
| 390 |
+
Constructors and member functions of `pair` shall not throw exceptions
|
| 391 |
unless one of the element-wise operations specified to be called for
|
| 392 |
that operation throws an exception.
|
| 393 |
|
| 394 |
+
The defaulted move and copy constructor, respectively, of pair shall be
|
| 395 |
+
a `constexpr` function if and only if all required element-wise
|
| 396 |
+
initializations for copy and move, respectively, would satisfy the
|
| 397 |
+
requirements for a `constexpr` function.
|
| 398 |
+
|
| 399 |
``` cpp
|
| 400 |
constexpr pair();
|
| 401 |
```
|
| 402 |
|
| 403 |
*Requires:* `is_default_constructible<first_type>::value` is `true` and
|
|
|
|
| 405 |
`ible<second_type>::value` is `true`.
|
| 406 |
|
| 407 |
*Effects:* Value-initializes `first` and `second`.
|
| 408 |
|
| 409 |
``` cpp
|
| 410 |
+
constexpr pair(const T1& x, const T2& y);
|
| 411 |
```
|
| 412 |
|
| 413 |
*Requires:* `is_copy_constructible<first_type>::value` is `true` and
|
| 414 |
`is_copy_constructible<second_type>::value` is `true`.
|
| 415 |
|
| 416 |
*Effects:* The constructor initializes `first` with `x` and `second`
|
| 417 |
with `y`.
|
| 418 |
|
| 419 |
``` cpp
|
| 420 |
+
template<class U, class V> constexpr pair(U&& x, V&& y);
|
| 421 |
```
|
| 422 |
|
| 423 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 424 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 425 |
|
|
|
|
| 429 |
*Remarks:* If `U` is not implicitly convertible to `first_type` or `V`
|
| 430 |
is not implicitly convertible to `second_type` this constructor shall
|
| 431 |
not participate in overload resolution.
|
| 432 |
|
| 433 |
``` cpp
|
| 434 |
+
template<class U, class V> constexpr pair(const pair<U, V>& p);
|
| 435 |
```
|
| 436 |
|
| 437 |
*Requires:* `is_constructible<first_type, const U&>::value` is `true`
|
| 438 |
and `is_constructible<second_type, const V&>::value` is `true`.
|
| 439 |
|
|
|
|
| 443 |
This constructor shall not participate in overload resolution unless
|
| 444 |
`const U&` is implicitly convertible to `first_type` and `const V&` is
|
| 445 |
implicitly convertible to `second_type`.
|
| 446 |
|
| 447 |
``` cpp
|
| 448 |
+
template<class U, class V> constexpr pair(pair<U, V>&& p);
|
| 449 |
```
|
| 450 |
|
| 451 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 452 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 453 |
|
|
|
|
| 463 |
template<class... Args1, class... Args2>
|
| 464 |
pair(piecewise_construct_t,
|
| 465 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 466 |
```
|
| 467 |
|
| 468 |
+
*Requires:* `is_constructible<first_type, Args1&&...>::value` is `true`
|
| 469 |
+
and `is_constructible<second_type, Args2&&...>::value` is `true`.
|
|
|
|
| 470 |
|
| 471 |
*Effects:* The constructor initializes `first` with arguments of types
|
| 472 |
`Args1...` obtained by forwarding the elements of `first_args` and
|
| 473 |
initializes `second` with arguments of types `Args2...` obtained by
|
| 474 |
forwarding the elements of `second_args`. (Here, forwarding an element
|
|
|
|
| 490 |
|
| 491 |
``` cpp
|
| 492 |
template<class U, class V> pair& operator=(const pair<U, V>& p);
|
| 493 |
```
|
| 494 |
|
| 495 |
+
*Requires:* `is_assignable<first_type&, const U&>::value` is `true` and
|
| 496 |
+
`is_assignable<second_type&, const V&>::value` is `true`.
|
| 497 |
|
| 498 |
*Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
|
| 499 |
|
| 500 |
*Returns:* `*this`.
|
| 501 |
|
|
|
|
| 551 |
|
| 552 |
### Specialized algorithms <a id="pairs.spec">[[pairs.spec]]</a>
|
| 553 |
|
| 554 |
``` cpp
|
| 555 |
template <class T1, class T2>
|
| 556 |
+
constexpr bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 557 |
```
|
| 558 |
|
| 559 |
*Returns:* `x.first == y.first && x.second == y.second`.
|
| 560 |
|
| 561 |
``` cpp
|
| 562 |
template <class T1, class T2>
|
| 563 |
+
constexpr bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 564 |
```
|
| 565 |
|
| 566 |
*Returns:*
|
| 567 |
`x.first < y.first || (!(y.first < x.first) && x.second < y.second)`.
|
| 568 |
|
| 569 |
``` cpp
|
| 570 |
template <class T1, class T2>
|
| 571 |
+
constexpr bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 572 |
```
|
| 573 |
|
| 574 |
*Returns:* `!(x == y)`
|
| 575 |
|
| 576 |
``` cpp
|
| 577 |
template <class T1, class T2>
|
| 578 |
+
constexpr bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 579 |
```
|
| 580 |
|
| 581 |
*Returns:* `y < x`
|
| 582 |
|
| 583 |
``` cpp
|
| 584 |
template <class T1, class T2>
|
| 585 |
+
constexpr bool operator>=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 586 |
```
|
| 587 |
|
| 588 |
*Returns:* `!(x < y)`
|
| 589 |
|
| 590 |
``` cpp
|
| 591 |
template <class T1, class T2>
|
| 592 |
+
constexpr bool operator<=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 593 |
```
|
| 594 |
|
| 595 |
*Returns:* `!(y < x)`
|
| 596 |
|
| 597 |
``` cpp
|
|
|
|
| 601 |
|
| 602 |
*Effects:* `x.swap(y)`
|
| 603 |
|
| 604 |
``` cpp
|
| 605 |
template <class T1, class T2>
|
| 606 |
+
constexpr pair<V1, V2> make_pair(T1&& x, T2&& y);
|
| 607 |
```
|
| 608 |
|
| 609 |
*Returns:* `pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))`;
|
| 610 |
|
| 611 |
+
where `V1` and `V2` are determined as follows: Let `Ui` be `decay_t<Ti>`
|
| 612 |
+
for each `Ti`. Then each `Vi` is `X&` if `Ui` equals
|
| 613 |
`reference_wrapper<X>`, otherwise `Vi` is `Ui`.
|
| 614 |
|
| 615 |
In place of:
|
| 616 |
|
| 617 |
``` cpp
|
|
|
|
| 625 |
```
|
| 626 |
|
| 627 |
### Tuple-like access to pair <a id="pair.astuple">[[pair.astuple]]</a>
|
| 628 |
|
| 629 |
``` cpp
|
| 630 |
+
template <class T1, class T2>
|
| 631 |
+
struct tuple_size<pair<T1, T2>>
|
| 632 |
+
: integral_constant<size_t, 2> { };
|
| 633 |
```
|
| 634 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
``` cpp
|
| 636 |
tuple_element<0, pair<T1, T2> >::type
|
| 637 |
```
|
| 638 |
|
| 639 |
*Value:* the type `T1`.
|
|
|
|
| 644 |
|
| 645 |
*Value:* the type T2.
|
| 646 |
|
| 647 |
``` cpp
|
| 648 |
template<size_t I, class T1, class T2>
|
| 649 |
+
constexpr tuple_element_t<I, pair<T1, T2>>&
|
| 650 |
+
get(pair<T1, T2>& p) noexcept;
|
| 651 |
template<size_t I, class T1, class T2>
|
| 652 |
+
constexpr const tuple_element_t<I, pair<T1, T2>>&
|
| 653 |
+
get(const pair<T1, T2>& p) noexcept;
|
| 654 |
```
|
| 655 |
|
| 656 |
*Returns:* If `I == 0` returns `p.first`; if `I == 1` returns
|
| 657 |
`p.second`; otherwise the program is ill-formed.
|
| 658 |
|
| 659 |
``` cpp
|
| 660 |
template<size_t I, class T1, class T2>
|
| 661 |
+
constexpr tuple_element_t<I, pair<T1, T2>>&&
|
| 662 |
+
get(pair<T1, T2>&& p) noexcept;
|
| 663 |
```
|
| 664 |
|
| 665 |
*Returns:* If `I == 0` returns `std::forward<T1&&>(p.first)`; if
|
| 666 |
`I == 1` returns `std::forward<T2&&>(p.second)`; otherwise the program
|
| 667 |
is ill-formed.
|
| 668 |
|
| 669 |
+
``` cpp
|
| 670 |
+
template <class T, class U>
|
| 671 |
+
constexpr T& get(pair<T, U>& p) noexcept;
|
| 672 |
+
template <class T, class U>
|
| 673 |
+
constexpr const T& get(const pair<T, U>& p) noexcept;
|
| 674 |
+
```
|
| 675 |
+
|
| 676 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 677 |
+
ill-formed.
|
| 678 |
+
|
| 679 |
+
*Returns:* `get<0>(p);`
|
| 680 |
+
|
| 681 |
+
``` cpp
|
| 682 |
+
template <class T, class U>
|
| 683 |
+
constexpr T&& get(pair<T, U>&& p) noexcept;
|
| 684 |
+
```
|
| 685 |
+
|
| 686 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 687 |
+
ill-formed.
|
| 688 |
+
|
| 689 |
+
*Returns:* `get<0>(std::move(p));`
|
| 690 |
+
|
| 691 |
+
``` cpp
|
| 692 |
+
template <class T, class U>
|
| 693 |
+
constexpr T& get(pair<U, T>& p) noexcept;
|
| 694 |
+
template <class T, class U>
|
| 695 |
+
constexpr const T& get(const pair<U, T>& p) noexcept;
|
| 696 |
+
```
|
| 697 |
+
|
| 698 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 699 |
+
ill-formed.
|
| 700 |
+
|
| 701 |
+
*Returns:* `get<1>(p);`
|
| 702 |
+
|
| 703 |
+
``` cpp
|
| 704 |
+
template <class T, class U>
|
| 705 |
+
constexpr T&& get(pair<U, T>&& p) noexcept;
|
| 706 |
+
```
|
| 707 |
+
|
| 708 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 709 |
+
ill-formed.
|
| 710 |
+
|
| 711 |
+
*Returns:* `get<1>(std::move(p));`
|
| 712 |
+
|
| 713 |
### Piecewise construction <a id="pair.piecewise">[[pair.piecewise]]</a>
|
| 714 |
|
| 715 |
``` cpp
|
| 716 |
struct piecewise_construct_t { };
|
| 717 |
+
constexpr piecewise_construct_t piecewise_construct{};
|
| 718 |
```
|
| 719 |
|
| 720 |
The `struct` `piecewise_construct_t` is an empty structure type used as
|
| 721 |
a unique type to disambiguate constructor and function overloading.
|
| 722 |
Specifically, `pair` has a constructor with `piecewise_construct_t` as
|
|
|
|
| 743 |
|
| 744 |
// [tuple.creation], tuple creation functions:
|
| 745 |
const unspecified ignore;
|
| 746 |
|
| 747 |
template <class... Types>
|
| 748 |
+
constexpr tuple<VTypes...> make_tuple(Types&&...);
|
| 749 |
template <class... Types>
|
| 750 |
+
constexpr tuple<Types&&...> forward_as_tuple(Types&&...) noexcept;
|
| 751 |
|
| 752 |
template<class... Types>
|
| 753 |
+
constexpr tuple<Types&...> tie(Types&...) noexcept;
|
| 754 |
|
| 755 |
template <class... Tuples>
|
| 756 |
+
constexpr tuple<Ctypes...> tuple_cat(Tuples&&...);
|
| 757 |
|
| 758 |
// [tuple.helper], tuple helper classes:
|
| 759 |
template <class T> class tuple_size; // undefined
|
| 760 |
template <class T> class tuple_size<const T>;
|
| 761 |
template <class T> class tuple_size<volatile T>;
|
|
|
|
| 768 |
template <size_t I, class T> class tuple_element<I, volatile T>;
|
| 769 |
template <size_t I, class T> class tuple_element<I, const volatile T>;
|
| 770 |
|
| 771 |
template <size_t I, class... Types> class tuple_element<I, tuple<Types...> >;
|
| 772 |
|
| 773 |
+
template <size_t I, class T>
|
| 774 |
+
using tuple_element_t = typename tuple_element<I, T>::type;
|
| 775 |
+
|
| 776 |
// [tuple.elem], element access:
|
| 777 |
template <size_t I, class... Types>
|
| 778 |
+
constexpr tuple_element_t<I, tuple<Types...>>&
|
| 779 |
+
get(tuple<Types...>&) noexcept;
|
| 780 |
+
template <size_t I, class... Types>
|
| 781 |
+
constexpr tuple_element_t<I, tuple<Types...>>&&
|
| 782 |
+
get(tuple<Types...>&&) noexcept;
|
| 783 |
+
template <size_t I, class... Types>
|
| 784 |
+
constexpr const tuple_element_t<I, tuple<Types...>>&
|
| 785 |
+
get(const tuple<Types...>&) noexcept;
|
| 786 |
+
template <class T, class... Types>
|
| 787 |
+
constexpr T& get(tuple<Types...>& t) noexcept;
|
| 788 |
+
template <class T, class... Types>
|
| 789 |
+
constexpr T&& get(tuple<Types...>&& t) noexcept;
|
| 790 |
+
template <class T, class... Types>
|
| 791 |
+
constexpr const T& get(const tuple<Types...>& t) noexcept;
|
| 792 |
|
| 793 |
// [tuple.rel], relational operators:
|
| 794 |
template<class... TTypes, class... UTypes>
|
| 795 |
+
constexpr bool operator==(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 796 |
template<class... TTypes, class... UTypes>
|
| 797 |
+
constexpr bool operator<(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 798 |
template<class... TTypes, class... UTypes>
|
| 799 |
+
constexpr bool operator!=(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 800 |
template<class... TTypes, class... UTypes>
|
| 801 |
+
constexpr bool operator>(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 802 |
template<class... TTypes, class... UTypes>
|
| 803 |
+
constexpr bool operator<=(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 804 |
template<class... TTypes, class... UTypes>
|
| 805 |
+
constexpr bool operator>=(const tuple<TTypes...>&, const tuple<UTypes...>&);
|
| 806 |
|
| 807 |
// [tuple.traits], allocator-related traits
|
| 808 |
template <class... Types, class Alloc>
|
| 809 |
struct uses_allocator<tuple<Types...>, Alloc>;
|
| 810 |
|
|
|
|
| 822 |
class tuple {
|
| 823 |
public:
|
| 824 |
|
| 825 |
// [tuple.cnstr], tuple construction
|
| 826 |
constexpr tuple();
|
| 827 |
+
constexpr explicit tuple(const Types&...);
|
| 828 |
template <class... UTypes>
|
| 829 |
+
constexpr explicit tuple(UTypes&&...);
|
| 830 |
|
| 831 |
tuple(const tuple&) = default;
|
| 832 |
tuple(tuple&&) = default;
|
| 833 |
|
| 834 |
template <class... UTypes>
|
| 835 |
+
constexpr tuple(const tuple<UTypes...>&);
|
| 836 |
template <class... UTypes>
|
| 837 |
+
constexpr tuple(tuple<UTypes...>&&);
|
| 838 |
|
| 839 |
template <class U1, class U2>
|
| 840 |
+
constexpr tuple(const pair<U1, U2>&); // only if sizeof...(Types) == 2
|
| 841 |
template <class U1, class U2>
|
| 842 |
+
constexpr tuple(pair<U1, U2>&&); // only if sizeof...(Types) == 2
|
| 843 |
|
| 844 |
// allocator-extended constructors
|
| 845 |
template <class Alloc>
|
| 846 |
tuple(allocator_arg_t, const Alloc& a);
|
| 847 |
template <class Alloc>
|
|
|
|
| 869 |
tuple& operator=(const tuple<UTypes...>&);
|
| 870 |
template <class... UTypes>
|
| 871 |
tuple& operator=(tuple<UTypes...>&&);
|
| 872 |
|
| 873 |
template <class U1, class U2>
|
| 874 |
+
tuple& operator=(const pair<U1, U2>&); // only if sizeof...(Types) == 2
|
| 875 |
template <class U1, class U2>
|
| 876 |
+
tuple& operator=(pair<U1, U2>&&); // only if sizeof...(Types) == 2
|
| 877 |
|
| 878 |
// [tuple.swap], tuple swap
|
| 879 |
void swap(tuple&) noexcept(see below);
|
| 880 |
};
|
| 881 |
}
|
|
|
|
| 884 |
#### Construction <a id="tuple.cnstr">[[tuple.cnstr]]</a>
|
| 885 |
|
| 886 |
For each `tuple` constructor, an exception is thrown only if the
|
| 887 |
construction of one of the types in `Types` throws an exception.
|
| 888 |
|
| 889 |
+
The defaulted move and copy constructor, respectively, of `tuple` shall
|
| 890 |
+
be a `constexpr` function if and only if all required element-wise
|
| 891 |
+
initializations for copy and move, respectively, would satisfy the
|
| 892 |
+
requirements for a `constexpr` function. The defaulted move and copy
|
| 893 |
+
constructor of `tuple<>` shall be `constexpr` functions.
|
| 894 |
+
|
| 895 |
In the constructor descriptions that follow, let i be in the range
|
| 896 |
\[`0`, `sizeof...(Types)`) in order, Tᵢ be the iᵗʰ type in `Types`, and
|
| 897 |
Uᵢ be the iᵗʰ type in a template parameter pack named `UTypes`, where
|
| 898 |
indexing is zero-based.
|
| 899 |
|
|
|
|
| 904 |
*Requires:* `is_default_constructible<`Tᵢ`>::value` is true for all i.
|
| 905 |
|
| 906 |
*Effects:* Value initializes each element.
|
| 907 |
|
| 908 |
``` cpp
|
| 909 |
+
constexpr explicit tuple(const Types&...);
|
| 910 |
```
|
| 911 |
|
| 912 |
*Requires:* `is_copy_constructible<`Tᵢ`>::value` is true for all i.
|
| 913 |
|
| 914 |
*Effects:* Initializes each element with the value of the corresponding
|
| 915 |
parameter.
|
| 916 |
|
| 917 |
``` cpp
|
| 918 |
template <class... UTypes>
|
| 919 |
+
constexpr explicit tuple(UTypes&&... u);
|
| 920 |
```
|
| 921 |
|
| 922 |
*Requires:* `sizeof...(Types)` `==` `sizeof...(UTypes)`.
|
| 923 |
`is_constructible<`Tᵢ`, `Uᵢ`&&>::value` is `true` for all i.
|
| 924 |
|
|
|
|
| 946 |
|
| 947 |
*Effects:* For all i, initializes the iᵗʰ element of `*this` with
|
| 948 |
`std::forward<`Tᵢ`>(get<`i`>(u))`.
|
| 949 |
|
| 950 |
``` cpp
|
| 951 |
+
template <class... UTypes> constexpr tuple(const tuple<UTypes...>& u);
|
| 952 |
```
|
| 953 |
|
| 954 |
*Requires:* `sizeof...(Types)` `==` `sizeof...(UTypes)`.
|
| 955 |
`is_constructible<`Tᵢ`, const `Uᵢ`&>::value` is `true` for all i.
|
| 956 |
|
|
|
|
| 959 |
|
| 960 |
This constructor shall not participate in overload resolution unless
|
| 961 |
`const `Uᵢ`&` is implicitly convertible to Tᵢ for all i.
|
| 962 |
|
| 963 |
``` cpp
|
| 964 |
+
template <class... UTypes> constexpr tuple(tuple<UTypes...>&& u);
|
| 965 |
```
|
| 966 |
|
| 967 |
*Requires:* `sizeof...(Types)` `==` `sizeof...(UTypes)`.
|
| 968 |
`is_constructible<`Tᵢ`, `Uᵢ`&&>::value` is `true` for all i.
|
| 969 |
|
|
|
|
| 973 |
This constructor shall not participate in overload resolution unless
|
| 974 |
each type in `UTypes` is implicitly convertible to its corresponding
|
| 975 |
type in `Types`.
|
| 976 |
|
| 977 |
``` cpp
|
| 978 |
+
template <class U1, class U2> constexpr tuple(const pair<U1, U2>& u);
|
| 979 |
```
|
| 980 |
|
| 981 |
*Requires:* `sizeof...(Types) == 2`.
|
| 982 |
`is_constructible<`T₀`, const U1&>::value` is `true` for the first type
|
| 983 |
T₀ in `Types` and `is_constructible<`T₁`, const U2&>::value` is `true`
|
|
|
|
| 989 |
This constructor shall not participate in overload resolution unless
|
| 990 |
`const U1&` is implicitly convertible to T₀ and `const U2&` is
|
| 991 |
implicitly convertible to T₁.
|
| 992 |
|
| 993 |
``` cpp
|
| 994 |
+
template <class U1, class U2> constexpr tuple(pair<U1, U2>&& u);
|
| 995 |
```
|
| 996 |
|
| 997 |
*Requires:* `sizeof...(Types) == 2`.
|
| 998 |
`is_constructible<`T₀`, U1&&>::value` is `true` for the first type T₀ in
|
| 999 |
`Types` and `is_constructible<`T₁`, U2&&>::value` is `true` for the
|
|
|
|
| 1142 |
|
| 1143 |
``` cpp
|
| 1144 |
noexcept(swap(declval<Tᵢ&>>(), declval<Tᵢ&>()))
|
| 1145 |
```
|
| 1146 |
|
| 1147 |
+
where Tᵢ is the iᵗʰ type in `Types`.
|
| 1148 |
|
| 1149 |
*Requires:* Each element in `*this` shall be swappable
|
| 1150 |
with ([[swappable.requirements]]) the corresponding element in `rhs`.
|
| 1151 |
|
| 1152 |
*Effects:* Calls `swap` for each element in `*this` and its
|
|
|
|
| 1163 |
`sizeof...(UTypes)`) in order and Uⱼ be the jᵗʰ type in a template
|
| 1164 |
parameter pack named `UTypes`, where indexing is zero-based.
|
| 1165 |
|
| 1166 |
``` cpp
|
| 1167 |
template<class... Types>
|
| 1168 |
+
constexpr tuple<VTypes...> make_tuple(Types&&... t);
|
| 1169 |
```
|
| 1170 |
|
| 1171 |
+
Let Uᵢ be `decay_t<`Tᵢ`>` for each Tᵢ in `Types`. Then each Vᵢ in
|
| 1172 |
`VTypes` is `X&` if Uᵢ equals `reference_wrapper<X>`, otherwise Vᵢ is
|
| 1173 |
Uᵢ.
|
| 1174 |
|
| 1175 |
*Returns:* `tuple<VTypes...>(std::forward<Types>(t)...)`.
|
| 1176 |
|
|
|
|
| 1185 |
tuple<int, int&, const float&>
|
| 1186 |
```
|
| 1187 |
|
| 1188 |
``` cpp
|
| 1189 |
template<class... Types>
|
| 1190 |
+
constexpr tuple<Types&&...> forward_as_tuple(Types&&... t) noexcept;
|
| 1191 |
```
|
| 1192 |
|
| 1193 |
*Effects:* Constructs a tuple of references to the arguments in `t`
|
| 1194 |
suitable for forwarding as arguments to a function. Because the result
|
| 1195 |
may contain references to temporary variables, a program shall ensure
|
|
|
|
| 1199 |
|
| 1200 |
*Returns:* `tuple<Types&&...>(std::forward<Types>(t)...)`
|
| 1201 |
|
| 1202 |
``` cpp
|
| 1203 |
template<class... Types>
|
| 1204 |
+
constexpr tuple<Types&...> tie(Types&... t) noexcept;
|
| 1205 |
```
|
| 1206 |
|
| 1207 |
+
*Returns:* `tuple<Types&...>(t...)`. When an argument in `t` is
|
| 1208 |
+
`ignore`, assigning any value to the corresponding tuple element has no
|
| 1209 |
+
effect.
|
| 1210 |
|
| 1211 |
`tie` functions allow one to create tuples that unpack tuples into
|
| 1212 |
variables. `ignore` can be used for elements that are not needed:
|
| 1213 |
|
| 1214 |
``` cpp
|
|
|
|
| 1217 |
// i == 42, s == "C++"
|
| 1218 |
```
|
| 1219 |
|
| 1220 |
``` cpp
|
| 1221 |
template <class... Tuples>
|
| 1222 |
+
constexpr tuple<CTypes...> tuple_cat(Tuples&&... tpls);
|
| 1223 |
```
|
| 1224 |
|
| 1225 |
In the following paragraphs, let Tᵢ be the iᵗʰ type in `Tuples`, Uᵢ be
|
| 1226 |
+
`remove_reference_t<Ti>`, and tpᵢ be the iᵗʰ parameter in the function
|
| 1227 |
+
parameter pack `tpls`, where all indexing is zero-based.
|
| 1228 |
|
| 1229 |
*Requires:* For all i, Uᵢ shall be the type cvᵢ `tuple<`Argsᵢ...`>`,
|
| 1230 |
where cvᵢ is the (possibly empty) iᵗʰ cv-qualifier-seq and Argsᵢ is the
|
| 1231 |
parameter pack representing the element types in Uᵢ. Let {Aᵢₖ} be the
|
| 1232 |
kᵢᵗʰ type in Argsᵢ. For all Aᵢₖ the following requirements shall be
|
|
|
|
| 1249 |
pack `Tuples` that support the `tuple`-like protocol, such as `pair` and
|
| 1250 |
`array`.
|
| 1251 |
|
| 1252 |
#### Tuple helper classes <a id="tuple.helper">[[tuple.helper]]</a>
|
| 1253 |
|
| 1254 |
+
``` cpp
|
| 1255 |
+
template <class T> struct tuple_size;
|
| 1256 |
+
```
|
| 1257 |
+
|
| 1258 |
+
*Remarks:* All specializations of `tuple_size<T>` shall meet the
|
| 1259 |
+
`UnaryTypeTrait` requirements ([[meta.rqmts]]) with a
|
| 1260 |
+
`BaseCharacteristic` of `integral_constant<size_t, N>` for some `N`.
|
| 1261 |
+
|
| 1262 |
``` cpp
|
| 1263 |
template <class... Types>
|
| 1264 |
class tuple_size<tuple<Types...> >
|
| 1265 |
: public integral_constant<size_t, sizeof...(Types)> { };
|
| 1266 |
```
|
|
|
|
| 1288 |
Let *TS* denote `tuple_size<T>` of the cv-unqualified type `T`. Then
|
| 1289 |
each of the three templates shall meet the `UnaryTypeTrait`
|
| 1290 |
requirements ([[meta.rqmts]]) with a `BaseCharacteristic` of
|
| 1291 |
|
| 1292 |
``` cpp
|
| 1293 |
+
integral_constant<size_t, TS::value>
|
| 1294 |
```
|
| 1295 |
|
| 1296 |
``` cpp
|
| 1297 |
template <size_t I, class T> class tuple_element<I, const T>;
|
| 1298 |
template <size_t I, class T> class tuple_element<I, volatile T>;
|
|
|
|
| 1302 |
Let *TE* denote `tuple_element<I, T>` of the cv-unqualified type `T`.
|
| 1303 |
Then each of the three templates shall meet the `TransformationTrait`
|
| 1304 |
requirements ([[meta.rqmts]]) with a member typedef `type` that names
|
| 1305 |
the following type:
|
| 1306 |
|
| 1307 |
+
- for the first specialization, `add_const_t<`*`TE`*`::type>`,
|
| 1308 |
+
- for the second specialization, `add_volatile_t<`*`TE`*`::type>`, and
|
| 1309 |
+
- for the third specialization, `add_cv_t<`*`TE`*`::type>`.
|
|
|
|
| 1310 |
|
| 1311 |
#### Element access <a id="tuple.elem">[[tuple.elem]]</a>
|
| 1312 |
|
| 1313 |
``` cpp
|
| 1314 |
template <size_t I, class... Types>
|
| 1315 |
+
constexpr tuple_element_t<I, tuple<Types...> >& get(tuple<Types...>& t) noexcept;
|
| 1316 |
```
|
| 1317 |
|
| 1318 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 1319 |
out of bounds.
|
| 1320 |
|
| 1321 |
*Returns:* A reference to the `I`th element of `t`, where indexing is
|
| 1322 |
zero-based.
|
| 1323 |
|
| 1324 |
``` cpp
|
| 1325 |
+
template <size_t I, class... Types>
|
| 1326 |
+
constexpr tuple_element_t<I, tuple<Types...> >&& get(tuple<Types...>&& t) noexcept;
|
| 1327 |
```
|
| 1328 |
|
| 1329 |
*Effects:* Equivalent to
|
| 1330 |
`return std::forward<typename tuple_element<I, tuple<Types...> >`
|
| 1331 |
`::type&&>(get<I>(t));`
|
|
|
|
| 1334 |
is `X&`, not `X&&`. However, if the element type is a non-reference type
|
| 1335 |
`T`, the return type is `T&&`.
|
| 1336 |
|
| 1337 |
``` cpp
|
| 1338 |
template <size_t I, class... Types>
|
| 1339 |
+
constexpr tuple_element_t<I, tuple<Types...> > const& get(const tuple<Types...>& t) noexcept;
|
| 1340 |
```
|
| 1341 |
|
| 1342 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 1343 |
out of bounds.
|
| 1344 |
|
|
|
|
| 1349 |
the return type is `X&`, not `const X&`. However, if the element type is
|
| 1350 |
non-reference type `T`, the return type is `const T&`. This is
|
| 1351 |
consistent with how constness is defined to work for member variables of
|
| 1352 |
reference type.
|
| 1353 |
|
| 1354 |
+
``` cpp
|
| 1355 |
+
template <class T, class... Types>
|
| 1356 |
+
constexpr T& get(tuple<Types...>& t) noexcept;
|
| 1357 |
+
template <class T, class... Types>
|
| 1358 |
+
constexpr T&& get(tuple<Types...>&& t) noexcept;
|
| 1359 |
+
template <class T, class... Types>
|
| 1360 |
+
constexpr const T& get(const tuple<Types...>& t) noexcept;
|
| 1361 |
+
```
|
| 1362 |
+
|
| 1363 |
+
*Requires:* The type `T` occurs exactly once in `Types...`. Otherwise,
|
| 1364 |
+
the program is ill-formed.
|
| 1365 |
+
|
| 1366 |
+
*Returns:* A reference to the element of `t` corresponding to the type
|
| 1367 |
+
`T` in `Types...`.
|
| 1368 |
+
|
| 1369 |
+
``` cpp
|
| 1370 |
+
const tuple<int, const int, double, double> t(1, 2, 3.4, 5.6);
|
| 1371 |
+
const int &i1 = get<int>(t); // OK. Not ambiguous. i1 == 1
|
| 1372 |
+
const int &i2 = get<const int>(t); // OK. Not ambiguous. i2 == 2
|
| 1373 |
+
const double &d = get<double>(t); // ERROR. ill-formed
|
| 1374 |
+
```
|
| 1375 |
+
|
| 1376 |
The reason `get` is a nonmember function is that if this functionality
|
| 1377 |
had been provided as a member function, code where the type depended on
|
| 1378 |
a template parameter would have required using the `template` keyword.
|
| 1379 |
|
| 1380 |
#### Relational operators <a id="tuple.rel">[[tuple.rel]]</a>
|
| 1381 |
|
| 1382 |
``` cpp
|
| 1383 |
template<class... TTypes, class... UTypes>
|
| 1384 |
+
constexpr bool operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1385 |
```
|
| 1386 |
|
| 1387 |
+
*Requires:* For all `i`, where `0 <= i` and `i < sizeof...(TTypes)`,
|
| 1388 |
`get<i>(t) == get<i>(u)` is a valid expression returning a type that is
|
| 1389 |
convertible to `bool`. `sizeof...(TTypes)` `==` `sizeof...(UTypes)`.
|
| 1390 |
|
| 1391 |
+
*Returns:* `true` if `get<i>(t) == get<i>(u)` for all `i`, otherwise
|
| 1392 |
+
`false`. For any two zero-length tuples `e` and `f`, `e == f` returns
|
| 1393 |
+
`true`.
|
| 1394 |
|
| 1395 |
*Effects:* The elementary comparisons are performed in order from the
|
| 1396 |
zeroth index upwards. No comparisons or element accesses are performed
|
| 1397 |
after the first equality comparison that evaluates to `false`.
|
| 1398 |
|
| 1399 |
``` cpp
|
| 1400 |
template<class... TTypes, class... UTypes>
|
| 1401 |
+
constexpr bool operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1402 |
```
|
| 1403 |
|
| 1404 |
+
*Requires:* For all `i`, where `0 <= i` and `i < sizeof...(TTypes)`,
|
| 1405 |
`get<i>(t) < get<i>(u)` and `get<i>(u) < get<i>(t)` are valid
|
| 1406 |
expressions returning types that are convertible to `bool`.
|
| 1407 |
`sizeof...(TTypes)` `==` `sizeof...(UTypes)`.
|
| 1408 |
|
| 1409 |
*Returns:* The result of a lexicographical comparison between `t` and
|
|
|
|
| 1413 |
element of `r`. For any two zero-length tuples `e` and `f`, `e < f`
|
| 1414 |
returns `false`.
|
| 1415 |
|
| 1416 |
``` cpp
|
| 1417 |
template<class... TTypes, class... UTypes>
|
| 1418 |
+
constexpr bool operator!=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1419 |
```
|
| 1420 |
|
| 1421 |
*Returns:* `!(t == u)`.
|
| 1422 |
|
| 1423 |
``` cpp
|
| 1424 |
template<class... TTypes, class... UTypes>
|
| 1425 |
+
constexpr bool operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1426 |
```
|
| 1427 |
|
| 1428 |
*Returns:* `u < t`.
|
| 1429 |
|
| 1430 |
``` cpp
|
| 1431 |
template<class... TTypes, class... UTypes>
|
| 1432 |
+
constexpr bool operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1433 |
```
|
| 1434 |
|
| 1435 |
*Returns:* `!(u < t)`
|
| 1436 |
|
| 1437 |
``` cpp
|
| 1438 |
template<class... TTypes, class... UTypes>
|
| 1439 |
+
constexpr bool operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
|
| 1440 |
```
|
| 1441 |
|
| 1442 |
*Returns:* `!(t < u)`
|
| 1443 |
|
| 1444 |
The above definitions for comparison operators do not require `tₜₐᵢₗ`
|
|
|
|
| 1474 |
noexcept(x.swap(y))
|
| 1475 |
```
|
| 1476 |
|
| 1477 |
*Effects:* `x.swap(y)`
|
| 1478 |
|
| 1479 |
+
## Compile-time integer sequences <a id="intseq">[[intseq]]</a>
|
| 1480 |
+
|
| 1481 |
+
### In general <a id="intseq.general">[[intseq.general]]</a>
|
| 1482 |
+
|
| 1483 |
+
The library provides a class template that can represent an integer
|
| 1484 |
+
sequence. When used as an argument to a function template the parameter
|
| 1485 |
+
pack defining the sequence can be deduced and used in a pack expansion.
|
| 1486 |
+
|
| 1487 |
+
``` cpp
|
| 1488 |
+
template<class F, class Tuple, std::size_t... I>
|
| 1489 |
+
decltype(auto) apply_impl(F&& f, Tuple&& t, index_sequence<I...>) {
|
| 1490 |
+
return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
|
| 1491 |
+
}
|
| 1492 |
+
|
| 1493 |
+
template<class F, class Tuple>
|
| 1494 |
+
decltype(auto) apply(F&& f, Tuple&& t) {
|
| 1495 |
+
using Indices = make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>;
|
| 1496 |
+
return apply_impl(std::forward<F>(f), std::forward<Tuple>(t), Indices());
|
| 1497 |
+
}
|
| 1498 |
+
```
|
| 1499 |
+
|
| 1500 |
+
The `index_sequence` alias template is provided for the common case of
|
| 1501 |
+
an integer sequence of type `size_t`.
|
| 1502 |
+
|
| 1503 |
+
### Class template `integer_sequence` <a id="intseq.intseq">[[intseq.intseq]]</a>
|
| 1504 |
+
|
| 1505 |
+
``` cpp
|
| 1506 |
+
namespace std {
|
| 1507 |
+
template<class T, T... I>
|
| 1508 |
+
struct integer_sequence {
|
| 1509 |
+
typedef T value_type;
|
| 1510 |
+
static constexpr size_t size() noexcept { return sizeof...(I); }
|
| 1511 |
+
};
|
| 1512 |
+
}
|
| 1513 |
+
```
|
| 1514 |
+
|
| 1515 |
+
`T` shall be an integer type.
|
| 1516 |
+
|
| 1517 |
+
### Alias template `make_integer_sequence` <a id="intseq.make">[[intseq.make]]</a>
|
| 1518 |
+
|
| 1519 |
+
``` cpp
|
| 1520 |
+
template<class T, T N>
|
| 1521 |
+
using make_integer_sequence = integer_sequence<T, see below>;
|
| 1522 |
+
```
|
| 1523 |
+
|
| 1524 |
+
If `N` is negative the program is ill-formed. The alias template
|
| 1525 |
+
`make_integer_sequence` denotes a specialization of `integer_sequence`
|
| 1526 |
+
with `N` template non-type arguments. The type
|
| 1527 |
+
`make_integer_sequence<T, N>` denotes the type
|
| 1528 |
+
`integer_sequence<T, 0, 1, ..., N-1>`. `make_integer_sequence<int, 0>`
|
| 1529 |
+
denotes the type `integer_sequence<int>`
|
| 1530 |
+
|
| 1531 |
## Class template `bitset` <a id="template.bitset">[[template.bitset]]</a>
|
| 1532 |
|
| 1533 |
\synopsis{Header \texttt{\<bitset\>} synopsis}
|
| 1534 |
|
| 1535 |
``` cpp
|
|
|
|
| 1615 |
class traits = char_traits<charT>,
|
| 1616 |
class Allocator = allocator<charT> >
|
| 1617 |
basic_string<charT, traits, Allocator>
|
| 1618 |
to_string(charT zero = charT('0'), charT one = charT('1')) const;
|
| 1619 |
size_t count() const noexcept;
|
| 1620 |
+
constexpr size_t size() const noexcept;
|
| 1621 |
bool operator==(const bitset<N>& rhs) const noexcept;
|
| 1622 |
bool operator!=(const bitset<N>& rhs) const noexcept;
|
| 1623 |
bool test(size_t pos) const;
|
| 1624 |
bool all() const noexcept;
|
| 1625 |
bool any() const noexcept;
|
|
|
|
| 1700 |
Otherwise, the function constructs an object of class `bitset<N>`,
|
| 1701 |
initializing the first `M` bit positions to values determined from the
|
| 1702 |
corresponding characters in the string `str`. `M` is the smaller of `N`
|
| 1703 |
and `rlen`.
|
| 1704 |
|
| 1705 |
+
An element of the constructed object has value zero if the corresponding
|
| 1706 |
+
character in `str`, beginning at position `pos`, is `zero`. Otherwise,
|
| 1707 |
+
the element has the value one. Character position `pos + M - 1`
|
| 1708 |
corresponds to bit position zero. Subsequent decreasing character
|
| 1709 |
positions correspond to increasing bit positions.
|
| 1710 |
|
| 1711 |
If `M < N`, remaining bit positions are initialized to zero.
|
| 1712 |
|
|
|
|
| 1899 |
```
|
| 1900 |
|
| 1901 |
*Returns:* A count of the number of bits set in `*this`.
|
| 1902 |
|
| 1903 |
``` cpp
|
| 1904 |
+
constexpr size_t size() const noexcept;
|
| 1905 |
```
|
| 1906 |
|
| 1907 |
*Returns:* `N`.
|
| 1908 |
|
| 1909 |
``` cpp
|
|
|
|
| 1960 |
```
|
| 1961 |
|
| 1962 |
*Returns:* `bitset<N>(*this) >>= pos`.
|
| 1963 |
|
| 1964 |
``` cpp
|
| 1965 |
+
constexpr bool operator[](size_t pos) const;
|
| 1966 |
```
|
| 1967 |
|
| 1968 |
*Requires:* `pos` shall be valid.
|
| 1969 |
|
| 1970 |
*Returns:* `true` if the bit at position `pos` in `*this` has the value
|
|
|
|
| 1993 |
|
| 1994 |
``` cpp
|
| 1995 |
template <size_t N> struct hash<bitset<N> >;
|
| 1996 |
```
|
| 1997 |
|
| 1998 |
+
The template specialization shall meet the requirements of class
|
| 1999 |
+
template `hash` ([[unord.hash]]).
|
| 2000 |
|
| 2001 |
### `bitset` operators <a id="bitset.operators">[[bitset.operators]]</a>
|
| 2002 |
|
| 2003 |
``` cpp
|
| 2004 |
bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
|
|
|
|
| 2063 |
|
| 2064 |
### In general <a id="memory.general">[[memory.general]]</a>
|
| 2065 |
|
| 2066 |
This subclause describes the contents of the header `<memory>` (
|
| 2067 |
[[memory.syn]]) and some of the contents of the C headers `<cstdlib>`
|
| 2068 |
+
and `<cstring>` ([[c.malloc]]).
|
| 2069 |
|
| 2070 |
### Header `<memory>` synopsis <a id="memory.syn">[[memory.syn]]</a>
|
| 2071 |
|
| 2072 |
The header `<memory>` defines several types and function templates that
|
| 2073 |
describe properties of pointers and pointer-like types, manage memory
|
| 2074 |
for containers and other template types, and construct multiple objects
|
| 2075 |
in uninitialized memory buffers ([[pointer.traits]]–
|
| 2076 |
[[specialized.algorithms]]). The header also defines the templates
|
| 2077 |
+
`unique_ptr`, `shared_ptr`, `weak_ptr`, and various function templates
|
| 2078 |
that operate on objects of these types ([[smartptr]]).
|
| 2079 |
|
| 2080 |
``` cpp
|
| 2081 |
namespace std {
|
| 2082 |
// [pointer.traits], pointer traits
|
|
|
|
| 2095 |
void* align(std::size_t alignment, std::size_t size,
|
| 2096 |
void*& ptr, std::size_t& space);
|
| 2097 |
|
| 2098 |
// [allocator.tag], allocator argument tag
|
| 2099 |
struct allocator_arg_t { };
|
| 2100 |
+
constexpr allocator_arg_t allocator_arg{};
|
| 2101 |
|
| 2102 |
// [allocator.uses], uses_allocator
|
| 2103 |
template <class T, class Alloc> struct uses_allocator;
|
| 2104 |
|
| 2105 |
// [allocator.traits], allocator traits
|
|
|
|
| 2140 |
template <class T> struct default_delete;
|
| 2141 |
template <class T> struct default_delete<T[]>;
|
| 2142 |
template <class T, class D = default_delete<T>> class unique_ptr;
|
| 2143 |
template <class T, class D> class unique_ptr<T[], D>;
|
| 2144 |
|
| 2145 |
+
template <class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
|
| 2146 |
+
template <class T> unique_ptr<T> make_unique(size_t n);
|
| 2147 |
+
template <class T, class... Args> unspecified make_unique(Args&&...) = delete;
|
| 2148 |
+
|
| 2149 |
+
template <class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
|
| 2150 |
+
|
| 2151 |
template <class T1, class D1, class T2, class D2>
|
| 2152 |
bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 2153 |
template <class T1, class D1, class T2, class D2>
|
| 2154 |
bool operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 2155 |
template <class T1, class D1, class T2, class D2>
|
|
|
|
| 2190 |
class bad_weak_ptr;
|
| 2191 |
|
| 2192 |
// [util.smartptr.shared], class template shared_ptr:
|
| 2193 |
template<class T> class shared_ptr;
|
| 2194 |
|
| 2195 |
+
// [util.smartptr.shared.create], shared_ptr creation
|
| 2196 |
+
template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
|
| 2197 |
+
template<class T, class A, class... Args>
|
| 2198 |
+
shared_ptr<T> allocate_shared(const A& a, Args&&... args);
|
| 2199 |
+
|
| 2200 |
// [util.smartptr.shared.cmp], shared_ptr comparisons:
|
| 2201 |
template<class T, class U>
|
| 2202 |
bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
|
| 2203 |
template<class T, class U>
|
| 2204 |
bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b) noexcept;
|
|
|
|
| 2372 |
``` cpp
|
| 2373 |
static pointer pointer_traits::pointer_to(see below r);
|
| 2374 |
static pointer pointer_traits<T*>::pointer_to(see below r) noexcept;
|
| 2375 |
```
|
| 2376 |
|
| 2377 |
+
If `element_type` is (possibly cv-qualified) `void`, the type of `r` is
|
| 2378 |
unspecified; otherwise, it is `element_type&`.
|
| 2379 |
|
| 2380 |
+
*Returns:* The first member function returns a pointer to `r` obtained
|
| 2381 |
+
by calling `Ptr::pointer_to(r)` through which indirection is valid; an
|
| 2382 |
+
instantiation of this function is ill-formed if `Ptr` does not have a
|
| 2383 |
+
matching `pointer_to` static member function. The second member function
|
| 2384 |
+
returns `std::addressof(r)`.
|
| 2385 |
|
| 2386 |
### Pointer safety <a id="util.dynamic.safety">[[util.dynamic.safety]]</a>
|
| 2387 |
|
| 2388 |
A complete object is *declared reachable* while the number of calls to
|
| 2389 |
`declare_reachable` with an argument referencing the object exceeds the
|
|
|
|
| 2434 |
call. In a garbage-collecting implementation, the fact that a region in
|
| 2435 |
an object is registered with `declare_no_pointers()` should not prevent
|
| 2436 |
the object from being collected.
|
| 2437 |
|
| 2438 |
*Effects:* The `n` bytes starting at `p` no longer contain traceable
|
| 2439 |
+
pointer locations, independent of their type. Hence indirection through
|
| 2440 |
+
a pointer located there is undefined if the object it points to was
|
| 2441 |
+
created by global `operator new` and not previously declared reachable.
|
| 2442 |
+
This may be used to inform a garbage collector or leak detector that
|
| 2443 |
+
this region of memory need not be traced.
|
| 2444 |
|
| 2445 |
*Throws:* Nothing.
|
| 2446 |
|
| 2447 |
Under some conditions implementations may need to allocate memory.
|
| 2448 |
However, the request can be ignored if memory allocation fails.
|
|
|
|
| 2499 |
### Allocator argument tag <a id="allocator.tag">[[allocator.tag]]</a>
|
| 2500 |
|
| 2501 |
``` cpp
|
| 2502 |
namespace std {
|
| 2503 |
struct allocator_arg_t { };
|
| 2504 |
+
constexpr allocator_arg_t allocator_arg{};
|
| 2505 |
}
|
| 2506 |
```
|
| 2507 |
|
| 2508 |
The `allocator_arg_t` struct is an empty structure type used as a unique
|
| 2509 |
type to disambiguate constructor and function overloading. Specifically,
|
|
|
|
| 2597 |
static void construct(Alloc& a, T* p, Args&&... args);
|
| 2598 |
|
| 2599 |
template <class T>
|
| 2600 |
static void destroy(Alloc& a, T* p);
|
| 2601 |
|
| 2602 |
+
static size_type max_size(const Alloc& a) noexcept;
|
| 2603 |
|
| 2604 |
static Alloc select_on_container_copy_construction(const Alloc& rhs);
|
| 2605 |
};
|
| 2606 |
}
|
| 2607 |
```
|
|
|
|
| 2646 |
``` cpp
|
| 2647 |
typedef see below size_type;
|
| 2648 |
```
|
| 2649 |
|
| 2650 |
*Type:* `Alloc::size_type` if such a type exists; otherwise,
|
| 2651 |
+
`make_unsigned_t<difference_type>`.
|
| 2652 |
|
| 2653 |
``` cpp
|
| 2654 |
typedef see below propagate_on_container_copy_assignment;
|
| 2655 |
```
|
| 2656 |
|
|
|
|
| 2719 |
|
| 2720 |
*Effects:* calls `a.destroy(p)` if that call is well-formed; otherwise,
|
| 2721 |
invokes `p->~T()`.
|
| 2722 |
|
| 2723 |
``` cpp
|
| 2724 |
+
static size_type max_size(const Alloc& a) noexcept;
|
| 2725 |
```
|
| 2726 |
|
| 2727 |
*Returns:* `a.max_size()` if that expression is well-formed; otherwise,
|
| 2728 |
`numeric_limits<size_type>::max()`.
|
| 2729 |
|
|
|
|
| 2758 |
typedef const T* const_pointer;
|
| 2759 |
typedef T& reference;
|
| 2760 |
typedef const T& const_reference;
|
| 2761 |
typedef T value_type;
|
| 2762 |
template <class U> struct rebind { typedef allocator<U> other; };
|
| 2763 |
+
typedef true_type propagate_on_container_move_assignment;
|
| 2764 |
|
| 2765 |
allocator() noexcept;
|
| 2766 |
allocator(const allocator&) noexcept;
|
| 2767 |
template <class U> allocator(const allocator<U>&) noexcept;
|
| 2768 |
~allocator();
|
|
|
|
| 2834 |
shall equal the value passed as the first argument to the invocation of
|
| 2835 |
allocate which returned `p`.
|
| 2836 |
|
| 2837 |
*Effects:* Deallocates the storage referenced by `p` .
|
| 2838 |
|
| 2839 |
+
*Remarks:* Uses
|
| 2840 |
+
`::operator delete(void*, std::size_t)` ([[new.delete]]), but it is
|
| 2841 |
unspecified when this function is called.
|
| 2842 |
|
| 2843 |
``` cpp
|
| 2844 |
size_type max_size() const noexcept;
|
| 2845 |
```
|
|
|
|
| 2878 |
*Returns:* `false`.
|
| 2879 |
|
| 2880 |
### Raw storage iterator <a id="storage.iterator">[[storage.iterator]]</a>
|
| 2881 |
|
| 2882 |
`raw_storage_iterator` is provided to enable algorithms to store their
|
| 2883 |
+
results into uninitialized memory. The template parameter
|
| 2884 |
`OutputIterator` is required to have its `operator*` return an object
|
| 2885 |
for which `operator&` is defined and returns a pointer to `T`, and is
|
| 2886 |
also required to satisfy the requirements of an output iterator (
|
| 2887 |
[[output.iterators]]).
|
| 2888 |
|
|
|
|
| 2892 |
class raw_storage_iterator
|
| 2893 |
: public iterator<output_iterator_tag,void,void,void,void> {
|
| 2894 |
public:
|
| 2895 |
explicit raw_storage_iterator(OutputIterator x);
|
| 2896 |
|
| 2897 |
+
raw_storage_iterator& operator*();
|
| 2898 |
+
raw_storage_iterator& operator=(const T& element);
|
| 2899 |
+
raw_storage_iterator& operator++();
|
| 2900 |
+
raw_storage_iterator operator++(int);
|
| 2901 |
};
|
| 2902 |
}
|
| 2903 |
```
|
| 2904 |
|
| 2905 |
``` cpp
|
|
|
|
| 2908 |
|
| 2909 |
*Effects:* Initializes the iterator to point to the same value to which
|
| 2910 |
`x` points.
|
| 2911 |
|
| 2912 |
``` cpp
|
| 2913 |
+
raw_storage_iterator& operator*();
|
| 2914 |
```
|
| 2915 |
|
| 2916 |
*Returns:* `*this`
|
| 2917 |
|
| 2918 |
``` cpp
|
| 2919 |
+
raw_storage_iterator& operator=(const T& element);
|
| 2920 |
```
|
| 2921 |
|
| 2922 |
*Effects:* Constructs a value from `element` at the location to which
|
| 2923 |
the iterator points.
|
| 2924 |
|
| 2925 |
*Returns:* A reference to the iterator.
|
| 2926 |
|
| 2927 |
``` cpp
|
| 2928 |
+
raw_storage_iterator& operator++();
|
| 2929 |
```
|
| 2930 |
|
| 2931 |
*Effects:* Pre-increment: advances the iterator and returns a reference
|
| 2932 |
to the updated iterator.
|
| 2933 |
|
| 2934 |
``` cpp
|
| 2935 |
+
raw_storage_iterator operator++(int);
|
| 2936 |
```
|
| 2937 |
|
| 2938 |
*Effects:* Post-increment: advances the iterator and returns the old
|
| 2939 |
value of the iterator.
|
| 2940 |
|
|
|
|
| 2962 |
*Requires:* The buffer shall have been previously allocated by
|
| 2963 |
`get_temporary_buffer`.
|
| 2964 |
|
| 2965 |
### Specialized algorithms <a id="specialized.algorithms">[[specialized.algorithms]]</a>
|
| 2966 |
|
| 2967 |
+
All the iterators that are used as template parameters in the following
|
| 2968 |
+
algorithms are required to have their `operator*` return an object for
|
| 2969 |
+
which `operator&` is defined and returns a pointer to `T`. In the
|
| 2970 |
+
algorithm `uninitialized_copy`, the template parameter `InputIterator`
|
| 2971 |
+
is required to satisfy the requirements of an input iterator (
|
| 2972 |
+
[[input.iterators]]). In all of the following algorithms, the template
|
| 2973 |
+
parameter `ForwardIterator` is required to satisfy the requirements of a
|
| 2974 |
+
forward iterator ([[forward.iterators]]), and is required to have the
|
| 2975 |
+
property that no exceptions are thrown from increment, assignment,
|
| 2976 |
+
comparison, or indirection through valid iterators. In the following
|
| 2977 |
+
algorithms, if an exception is thrown there are no effects.
|
|
|
|
| 2978 |
|
| 2979 |
#### `addressof` <a id="specialized.addressof">[[specialized.addressof]]</a>
|
| 2980 |
|
| 2981 |
``` cpp
|
| 2982 |
template <class T> T* addressof(T& r) noexcept;
|
|
|
|
| 3140 |
template<class T> struct default_delete<T[]>;
|
| 3141 |
|
| 3142 |
template<class T, class D = default_delete<T>> class unique_ptr;
|
| 3143 |
template<class T, class D> class unique_ptr<T[], D>;
|
| 3144 |
|
| 3145 |
+
template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
|
| 3146 |
+
template<class T> unique_ptr<T> make_unique(size_t n);
|
| 3147 |
+
template<class T, class... Args> unspecified make_unique(Args&&...) = delete;
|
| 3148 |
+
|
| 3149 |
template<class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
|
| 3150 |
|
| 3151 |
template<class T1, class D1, class T2, class D2>
|
| 3152 |
bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 3153 |
template<class T1, class D1, class T2, class D2>
|
|
|
|
| 3279 |
unique_ptr& operator=(unique_ptr&& u) noexcept;
|
| 3280 |
template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
|
| 3281 |
unique_ptr& operator=(nullptr_t) noexcept;
|
| 3282 |
|
| 3283 |
// [unique.ptr.single.observers], observers
|
| 3284 |
+
add_lvalue_reference_t<T> operator*() const;
|
| 3285 |
pointer operator->() const noexcept;
|
| 3286 |
pointer get() const noexcept;
|
| 3287 |
deleter_type& get_deleter() noexcept;
|
| 3288 |
const deleter_type& get_deleter() const noexcept;
|
| 3289 |
explicit operator bool() const noexcept;
|
|
|
|
| 3309 |
for that deleter.
|
| 3310 |
|
| 3311 |
If the deleter’s type `D` is not a reference type, `D` shall satisfy the
|
| 3312 |
requirements of `Destructible` (Table [[destructible]]).
|
| 3313 |
|
| 3314 |
+
If the type `remove_reference_t<D>::pointer` exists, then `unique_ptr<T,
|
| 3315 |
+
D>::pointer` shall be a synonym for `remove_reference_t<D>::pointer`.
|
| 3316 |
+
Otherwise `unique_ptr<T, D>::pointer` shall be a synonym for `T*`. The
|
| 3317 |
+
type `unique_ptr<T,
|
|
|
|
|
|
|
| 3318 |
D>::pointer` shall satisfy the requirements of `NullablePointer` (
|
| 3319 |
[[nullablepointer.requirements]]).
|
| 3320 |
|
| 3321 |
Given an allocator type `X` ([[allocator.requirements]]) and letting
|
| 3322 |
`A` be a synonym for `allocator_traits<X>`, the types `A::pointer`,
|
|
|
|
| 3512 |
```
|
| 3513 |
|
| 3514 |
*Requires:* If `D` is not a reference type, `D` shall satisfy the
|
| 3515 |
requirements of `MoveAssignable` (Table [[moveassignable]]) and
|
| 3516 |
assignment of the deleter from an rvalue of type `D` shall not throw an
|
| 3517 |
+
exception. Otherwise, `D` is a reference type; `remove_reference_t<D>`
|
| 3518 |
+
shall satisfy the `CopyAssignable` requirements and assignment of the
|
| 3519 |
+
deleter from an lvalue of type `D` shall not throw an exception.
|
|
|
|
| 3520 |
|
| 3521 |
*Effects:* Transfers ownership from `u` to `*this` as if by calling
|
| 3522 |
+
`reset(u.release())` followed by
|
| 3523 |
+
`get_deleter() = std::forward<D>(u.get_deleter())`.
|
| 3524 |
|
| 3525 |
*Returns:* `*this`.
|
| 3526 |
|
| 3527 |
``` cpp
|
| 3528 |
template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
|
|
|
|
| 3539 |
|
| 3540 |
- `unique_ptr<U, E>::pointer` is implicitly convertible to `pointer` and
|
| 3541 |
- `U` is not an array type.
|
| 3542 |
|
| 3543 |
*Effects:* Transfers ownership from `u` to `*this` as if by calling
|
| 3544 |
+
`reset(u.release())` followed by
|
| 3545 |
+
`get_deleter() = std::forward<E>(u.get_deleter())`.
|
| 3546 |
|
| 3547 |
*Returns:* `*this`.
|
| 3548 |
|
| 3549 |
``` cpp
|
| 3550 |
unique_ptr& operator=(nullptr_t) noexcept;
|
|
|
|
| 3557 |
*Returns:* `*this`.
|
| 3558 |
|
| 3559 |
##### `unique_ptr` observers <a id="unique.ptr.single.observers">[[unique.ptr.single.observers]]</a>
|
| 3560 |
|
| 3561 |
``` cpp
|
| 3562 |
+
add_lvalue_reference_t<T> operator*() const;
|
| 3563 |
```
|
| 3564 |
|
| 3565 |
*Requires:* `get() != nullptr`.
|
| 3566 |
|
| 3567 |
*Returns:* `*get()`.
|
|
|
|
| 3720 |
*Returns:* `get()[i]`.
|
| 3721 |
|
| 3722 |
##### `unique_ptr` modifiers <a id="unique.ptr.runtime.modifiers">[[unique.ptr.runtime.modifiers]]</a>
|
| 3723 |
|
| 3724 |
``` cpp
|
|
|
|
| 3725 |
void reset(nullptr_t p) noexcept;
|
| 3726 |
```
|
| 3727 |
|
| 3728 |
+
*Effects:* Equivalent to `reset(pointer())`.
|
|
|
|
| 3729 |
|
| 3730 |
+
#### `unique_ptr` creation <a id="unique.ptr.create">[[unique.ptr.create]]</a>
|
| 3731 |
+
|
| 3732 |
+
``` cpp
|
| 3733 |
+
template <class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
|
| 3734 |
+
```
|
| 3735 |
+
|
| 3736 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 3737 |
+
unless `T` is not an array.
|
| 3738 |
+
|
| 3739 |
+
*Returns:* `unique_ptr<T>(new T(std::forward<Args>(args)...))`.
|
| 3740 |
+
|
| 3741 |
+
``` cpp
|
| 3742 |
+
template <class T> unique_ptr<T> make_unique(size_t n);
|
| 3743 |
+
```
|
| 3744 |
+
|
| 3745 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 3746 |
+
unless `T` is an array of unknown bound.
|
| 3747 |
+
|
| 3748 |
+
*Returns:* `unique_ptr<T>(new remove_extent_t<T>[n]())`.
|
| 3749 |
+
|
| 3750 |
+
``` cpp
|
| 3751 |
+
template <class T, class... Args> unspecified make_unique(Args&&...) = delete;
|
| 3752 |
+
```
|
| 3753 |
+
|
| 3754 |
+
*Remarks:* This function shall not participate in overload resolution
|
| 3755 |
+
unless `T` is an array of known bound.
|
| 3756 |
|
| 3757 |
#### `unique_ptr` specialized algorithms <a id="unique.ptr.special">[[unique.ptr.special]]</a>
|
| 3758 |
|
| 3759 |
``` cpp
|
| 3760 |
template <class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
|
|
|
|
| 3916 |
// [util.smartptr.shared.const], constructors:
|
| 3917 |
constexpr shared_ptr() noexcept;
|
| 3918 |
template<class Y> explicit shared_ptr(Y* p);
|
| 3919 |
template<class Y, class D> shared_ptr(Y* p, D d);
|
| 3920 |
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
|
| 3921 |
+
template <class D> shared_ptr(nullptr_t p, D d);
|
| 3922 |
+
template <class D, class A> shared_ptr(nullptr_t p, D d, A a);
|
| 3923 |
template<class Y> shared_ptr(const shared_ptr<Y>& r, T* p) noexcept;
|
| 3924 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 3925 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 3926 |
shared_ptr(shared_ptr&& r) noexcept;
|
| 3927 |
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
|
|
|
|
| 4048 |
constexpr shared_ptr() noexcept;
|
| 4049 |
```
|
| 4050 |
|
| 4051 |
*Effects:* Constructs an *empty* `shared_ptr` object.
|
| 4052 |
|
| 4053 |
+
*Postconditions:* `use_count() == 0 && get() == nullptr`.
|
| 4054 |
|
| 4055 |
``` cpp
|
| 4056 |
template<class Y> explicit shared_ptr(Y* p);
|
| 4057 |
```
|
| 4058 |
|
|
|
|
| 4106 |
To avoid the possibility of a dangling pointer, the user of this
|
| 4107 |
constructor must ensure that `p` remains valid at least until the
|
| 4108 |
ownership group of `r` is destroyed.
|
| 4109 |
|
| 4110 |
This constructor allows creation of an *empty* `shared_ptr` instance
|
| 4111 |
+
with a non-null stored pointer.
|
| 4112 |
|
| 4113 |
``` cpp
|
| 4114 |
shared_ptr(const shared_ptr& r) noexcept;
|
| 4115 |
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 4116 |
```
|
| 4117 |
|
| 4118 |
+
The second constructor shall not participate in overload resolution
|
| 4119 |
+
unless `Y*` is implicitly convertible to `T*`.
|
| 4120 |
|
| 4121 |
*Effects:* If `r` is *empty*, constructs an *empty* `shared_ptr` object;
|
| 4122 |
otherwise, constructs a `shared_ptr` object that *shares ownership* with
|
| 4123 |
`r`.
|
| 4124 |
|
|
|
|
| 4133 |
unless `Y*` is convertible to `T*`.
|
| 4134 |
|
| 4135 |
*Effects:* Move-constructs a `shared_ptr` instance from `r`.
|
| 4136 |
|
| 4137 |
*Postconditions:* `*this` shall contain the old value of `r`. `r` shall
|
| 4138 |
+
be *empty*. `r.get() == nullptr.`
|
| 4139 |
|
| 4140 |
``` cpp
|
| 4141 |
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
|
| 4142 |
```
|
| 4143 |
|
|
|
|
| 4161 |
shall have well defined behavior, and shall not throw exceptions.
|
| 4162 |
|
| 4163 |
*Effects:* Constructs a `shared_ptr` object that stores and *owns*
|
| 4164 |
`r.release()`.
|
| 4165 |
|
| 4166 |
+
*Postconditions:* `use_count() == 1` `&&` `r.get() == nullptr`.
|
| 4167 |
|
| 4168 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 4169 |
resource other than memory could not be obtained.
|
| 4170 |
|
| 4171 |
If an exception is thrown, the constructor has no effect.
|
|
|
|
| 4318 |
|
| 4319 |
*Returns:* `use_count() == 1`.
|
| 4320 |
|
| 4321 |
`unique()` may be faster than `use_count()`. If you are using `unique()`
|
| 4322 |
to implement copy on write, do not rely on a specific value when
|
| 4323 |
+
`get() == nullptr`.
|
| 4324 |
|
| 4325 |
``` cpp
|
| 4326 |
explicit operator bool() const noexcept;
|
| 4327 |
```
|
| 4328 |
|
|
|
|
| 4368 |
*Postconditions:* `get() != 0 && use_count() == 1`
|
| 4369 |
|
| 4370 |
*Throws:* `bad_alloc`, or an exception thrown from `A::allocate` or from
|
| 4371 |
the constructor of `T`.
|
| 4372 |
|
| 4373 |
+
*Remarks:* Implementations should perform no more than one memory
|
| 4374 |
+
allocation. This provides efficiency equivalent to an intrusive smart
|
| 4375 |
+
pointer.
|
| 4376 |
|
| 4377 |
These functions will typically allocate more memory than `sizeof(T)` to
|
| 4378 |
allow for internal bookkeeping structures such as the reference counts.
|
| 4379 |
|
| 4380 |
##### `shared_ptr` comparison <a id="util.smartptr.shared.cmp">[[util.smartptr.shared.cmp]]</a>
|
|
|
|
| 4388 |
``` cpp
|
| 4389 |
template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b) noexcept;
|
| 4390 |
```
|
| 4391 |
|
| 4392 |
*Returns:* `less<V>()(a.get(), b.get())`, where `V` is the composite
|
| 4393 |
+
pointer type (Clause [[expr]]) of `T*` and `U*`.
|
| 4394 |
|
| 4395 |
Defining a comparison operator allows `shared_ptr` objects to be used as
|
| 4396 |
keys in associative containers.
|
| 4397 |
|
| 4398 |
``` cpp
|
|
|
|
| 4525 |
``` cpp
|
| 4526 |
template<class D, class T> D* get_deleter(const shared_ptr<T>& p) noexcept;
|
| 4527 |
```
|
| 4528 |
|
| 4529 |
*Returns:* If `p` *owns* a deleter `d` of type cv-unqualified `D`,
|
| 4530 |
+
returns `&d`; otherwise returns `nullptr`. The returned pointer remains
|
| 4531 |
+
valid as long as there exists a `shared_ptr` instance that owns `d`. It
|
| 4532 |
+
is unspecified whether the pointer remains valid longer than that. This
|
| 4533 |
+
can happen if the implementation doesn’t destroy the deleter until all
|
| 4534 |
`weak_ptr` instances that share ownership with `p` have been destroyed.
|
| 4535 |
|
| 4536 |
##### `shared_ptr` I/O <a id="util.smartptr.shared.io">[[util.smartptr.shared.io]]</a>
|
| 4537 |
|
| 4538 |
``` cpp
|
|
|
|
| 4559 |
// [util.smartptr.weak.const], constructors
|
| 4560 |
constexpr weak_ptr() noexcept;
|
| 4561 |
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
|
| 4562 |
weak_ptr(weak_ptr const& r) noexcept;
|
| 4563 |
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
|
| 4564 |
+
weak_ptr(weak_ptr&& r) noexcept;
|
| 4565 |
+
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
|
| 4566 |
|
| 4567 |
// [util.smartptr.weak.dest], destructor
|
| 4568 |
~weak_ptr();
|
| 4569 |
|
| 4570 |
// [util.smartptr.weak.assign], assignment
|
| 4571 |
weak_ptr& operator=(weak_ptr const& r) noexcept;
|
| 4572 |
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
|
| 4573 |
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
|
| 4574 |
+
weak_ptr& operator=(weak_ptr&& r) noexcept;
|
| 4575 |
+
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
|
| 4576 |
|
| 4577 |
// [util.smartptr.weak.mod], modifiers
|
| 4578 |
void swap(weak_ptr& r) noexcept;
|
| 4579 |
void reset() noexcept;
|
| 4580 |
|
| 4581 |
// [util.smartptr.weak.obs], observers
|
| 4582 |
long use_count() const noexcept;
|
| 4583 |
bool expired() const noexcept;
|
| 4584 |
shared_ptr<T> lock() const noexcept;
|
| 4585 |
+
template<class U> bool owner_before(shared_ptr<U> const& b) const;
|
| 4586 |
+
template<class U> bool owner_before(weak_ptr<U> const& b) const;
|
| 4587 |
};
|
| 4588 |
|
| 4589 |
// [util.smartptr.weak.spec], specialized algorithms
|
| 4590 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 4591 |
} // namespace std
|
|
|
|
| 4609 |
weak_ptr(const weak_ptr& r) noexcept;
|
| 4610 |
template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept;
|
| 4611 |
template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept;
|
| 4612 |
```
|
| 4613 |
|
| 4614 |
+
The second and third constructors shall not participate in overload
|
| 4615 |
+
resolution unless `Y*` is implicitly convertible to `T*`.
|
| 4616 |
|
| 4617 |
*Effects:* If `r` is *empty*, constructs an *empty* `weak_ptr` object;
|
| 4618 |
otherwise, constructs a `weak_ptr` object that *shares ownership* with
|
| 4619 |
`r` and stores a copy of the pointer stored in `r`.
|
| 4620 |
|
| 4621 |
*Postconditions:* `use_count() == r.use_count()`.
|
| 4622 |
|
| 4623 |
+
``` cpp
|
| 4624 |
+
weak_ptr(weak_ptr&& r) noexcept;
|
| 4625 |
+
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
|
| 4626 |
+
```
|
| 4627 |
+
|
| 4628 |
+
The second constructor shall not participate in overload resolution
|
| 4629 |
+
unless `Y*` is implicitly convertible to `T*`.
|
| 4630 |
+
|
| 4631 |
+
*Effects:* Move-constructs a `weak_ptr` instance from `r`.
|
| 4632 |
+
|
| 4633 |
+
*Postconditions:* `*this` shall contain the old value of `r`. `r` shall
|
| 4634 |
+
be *empty*. `r.use_count() == 0`.
|
| 4635 |
+
|
| 4636 |
##### `weak_ptr` destructor <a id="util.smartptr.weak.dest">[[util.smartptr.weak.dest]]</a>
|
| 4637 |
|
| 4638 |
``` cpp
|
| 4639 |
~weak_ptr();
|
| 4640 |
```
|
|
|
|
| 4653 |
*Effects:* Equivalent to `weak_ptr(r).swap(*this)`.
|
| 4654 |
|
| 4655 |
*Remarks:* The implementation may meet the effects (and the implied
|
| 4656 |
guarantees) via different means, without creating a temporary.
|
| 4657 |
|
| 4658 |
+
*Returns:* `*this`.
|
| 4659 |
+
|
| 4660 |
+
``` cpp
|
| 4661 |
+
weak_ptr& operator=(weak_ptr&& r) noexcept;
|
| 4662 |
+
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
|
| 4663 |
+
```
|
| 4664 |
+
|
| 4665 |
+
*Effects:* Equivalent to `weak_ptr(std::move(r)).swap(*this)`.
|
| 4666 |
+
|
| 4667 |
+
*Returns:* `*this`.
|
| 4668 |
+
|
| 4669 |
##### `weak_ptr` modifiers <a id="util.smartptr.weak.mod">[[util.smartptr.weak.mod]]</a>
|
| 4670 |
|
| 4671 |
``` cpp
|
| 4672 |
void swap(weak_ptr& r) noexcept;
|
| 4673 |
```
|
|
|
|
| 4701 |
|
| 4702 |
``` cpp
|
| 4703 |
shared_ptr<T> lock() const noexcept;
|
| 4704 |
```
|
| 4705 |
|
| 4706 |
+
*Returns:* `expired() ? shared_ptr<T>() : shared_ptr<T>(*this)`,
|
| 4707 |
+
executed atomically.
|
| 4708 |
|
| 4709 |
``` cpp
|
| 4710 |
+
template<class U> bool owner_before(shared_ptr<U> const& b) const;
|
| 4711 |
+
template<class U> bool owner_before(weak_ptr<U> const& b) const;
|
| 4712 |
```
|
| 4713 |
|
| 4714 |
*Returns:* An unspecified value such that
|
| 4715 |
|
| 4716 |
- `x.owner_before(y)` defines a strict weak ordering as defined
|
|
|
|
| 4726 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 4727 |
```
|
| 4728 |
|
| 4729 |
*Effects:* Equivalent to `a.swap(b)`.
|
| 4730 |
|
| 4731 |
+
#### Class template `owner_less` <a id="util.smartptr.ownerless">[[util.smartptr.ownerless]]</a>
|
| 4732 |
|
| 4733 |
The class template `owner_less` allows ownership-based mixed comparisons
|
| 4734 |
of shared and weak pointers.
|
| 4735 |
|
| 4736 |
``` cpp
|
|
|
|
| 4957 |
template<class T>
|
| 4958 |
bool atomic_compare_exchange_weak(
|
| 4959 |
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
|
| 4960 |
```
|
| 4961 |
|
| 4962 |
+
*Requires:* `p` shall not be null and `v` shall not be null.
|
| 4963 |
|
| 4964 |
*Returns:*
|
| 4965 |
`atomic_compare_exchange_weak_explicit(p, v, w, memory_order_seq_cst, memory_order_seq_cst)`.
|
| 4966 |
|
| 4967 |
*Throws:* Nothing.
|
|
|
|
| 4984 |
bool atomic_compare_exchange_strong_explicit(
|
| 4985 |
shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w,
|
| 4986 |
memory_order success, memory_order failure);
|
| 4987 |
```
|
| 4988 |
|
| 4989 |
+
*Requires:* `p` shall not be null and `v` shall not be null.
|
| 4990 |
|
| 4991 |
*Requires:* `failure` shall not be `memory_order_release`,
|
| 4992 |
`memory_order_acq_rel`, or stronger than `success`.
|
| 4993 |
|
| 4994 |
*Effects:* If `*p` is equivalent to `*v`, assigns `w` to `*p` and has
|
|
|
|
| 5010 |
|
| 5011 |
``` cpp
|
| 5012 |
template <class T, class D> struct hash<unique_ptr<T, D> >;
|
| 5013 |
```
|
| 5014 |
|
| 5015 |
+
The template specialization shall meet the requirements of class
|
| 5016 |
+
template `hash` ([[unord.hash]]). For an object `p` of type `UP`, where
|
| 5017 |
+
`UP` is `unique_ptr<T, D>`, `hash<UP>()(p)` shall evaluate to the same
|
| 5018 |
+
value as `hash<typename UP::pointer>()(p.get())`.
|
| 5019 |
+
|
| 5020 |
+
*Requires:* The specialization `hash<typename UP::pointer>` shall be
|
| 5021 |
+
well-formed and well-defined, and shall meet the requirements of class
|
| 5022 |
+
template `hash` ([[unord.hash]]).
|
| 5023 |
|
| 5024 |
``` cpp
|
| 5025 |
template <class T> struct hash<shared_ptr<T> >;
|
| 5026 |
```
|
| 5027 |
|
| 5028 |
+
The template specialization shall meet the requirements of class
|
| 5029 |
+
template `hash` ([[unord.hash]]). For an object `p` of type
|
| 5030 |
`shared_ptr<T>`, `hash<shared_ptr<T> >()(p)` shall evaluate to the same
|
| 5031 |
value as `hash<T*>()(p.get())`.
|
| 5032 |
|
| 5033 |
## Function objects <a id="function.objects">[[function.objects]]</a>
|
| 5034 |
|
|
|
|
| 5058 |
|
| 5059 |
template <class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
|
| 5060 |
template <class T> reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
|
| 5061 |
|
| 5062 |
// [arithmetic.operations], arithmetic operations:
|
| 5063 |
+
template <class T = void> struct plus;
|
| 5064 |
+
template <class T = void> struct minus;
|
| 5065 |
+
template <class T = void> struct multiplies;
|
| 5066 |
+
template <class T = void> struct divides;
|
| 5067 |
+
template <class T = void> struct modulus;
|
| 5068 |
+
template <class T = void> struct negate;
|
| 5069 |
+
template <> struct plus<void>;
|
| 5070 |
+
template <> struct minus<void>;
|
| 5071 |
+
template <> struct multiplies<void>;
|
| 5072 |
+
template <> struct divides<void>;
|
| 5073 |
+
template <> struct modulus<void>;
|
| 5074 |
+
template <> struct negate<void>;
|
| 5075 |
|
| 5076 |
// [comparisons], comparisons:
|
| 5077 |
+
template <class T = void> struct equal_to;
|
| 5078 |
+
template <class T = void> struct not_equal_to;
|
| 5079 |
+
template <class T = void> struct greater;
|
| 5080 |
+
template <class T = void> struct less;
|
| 5081 |
+
template <class T = void> struct greater_equal;
|
| 5082 |
+
template <class T = void> struct less_equal;
|
| 5083 |
+
template <> struct equal_to<void>;
|
| 5084 |
+
template <> struct not_equal_to<void>;
|
| 5085 |
+
template <> struct greater<void>;
|
| 5086 |
+
template <> struct less<void>;
|
| 5087 |
+
template <> struct greater_equal<void>;
|
| 5088 |
+
template <> struct less_equal<void>;
|
| 5089 |
|
| 5090 |
// [logical.operations], logical operations:
|
| 5091 |
+
template <class T = void> struct logical_and;
|
| 5092 |
+
template <class T = void> struct logical_or;
|
| 5093 |
+
template <class T = void> struct logical_not;
|
| 5094 |
+
template <> struct logical_and<void>;
|
| 5095 |
+
template <> struct logical_or<void>;
|
| 5096 |
+
template <> struct logical_not<void>;
|
| 5097 |
|
| 5098 |
// [bitwise.operations], bitwise operations:
|
| 5099 |
+
template <class T = void> struct bit_and;
|
| 5100 |
+
template <class T = void> struct bit_or;
|
| 5101 |
+
template <class T = void> struct bit_xor;
|
| 5102 |
+
template <class T = void> struct bit_not;
|
| 5103 |
+
template <> struct bit_and<void>;
|
| 5104 |
+
template <> struct bit_or<void>;
|
| 5105 |
+
template <> struct bit_xor<void>;
|
| 5106 |
+
template <> struct bit_not<void>;
|
| 5107 |
|
| 5108 |
// [negators], negators:
|
| 5109 |
template <class Predicate> class unary_negate;
|
| 5110 |
template <class Predicate>
|
| 5111 |
+
constexpr unary_negate<Predicate> not1(const Predicate&);
|
| 5112 |
template <class Predicate> class binary_negate;
|
| 5113 |
template <class Predicate>
|
| 5114 |
+
constexpr binary_negate<Predicate> not2(const Predicate&);
|
| 5115 |
|
| 5116 |
+
// [func.bind], bind:
|
| 5117 |
template<class T> struct is_bind_expression;
|
| 5118 |
template<class T> struct is_placeholder;
|
| 5119 |
|
| 5120 |
template<class F, class... BoundArgs>
|
| 5121 |
unspecified bind(F&&, BoundArgs&&...);
|
|
|
|
| 5177 |
template <class S, class T, class A>
|
| 5178 |
const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
|
| 5179 |
|
| 5180 |
// [func.memfn], member function adaptors:
|
| 5181 |
template<class R, class T> unspecified mem_fn(R T::*);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5182 |
|
| 5183 |
// [func.wrap] polymorphic function wrappers:
|
| 5184 |
class bad_function_call;
|
| 5185 |
|
| 5186 |
template<class> class function; // undefined
|
|
|
|
| 5196 |
template<class R, class... ArgTypes>
|
| 5197 |
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
|
| 5198 |
template<class R, class... ArgTypes>
|
| 5199 |
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
|
| 5200 |
|
| 5201 |
+
// [unord.hash], hash function primary template:
|
| 5202 |
template <class T> struct hash;
|
| 5203 |
|
| 5204 |
// Hash function specializations
|
| 5205 |
template <> struct hash<bool>;
|
| 5206 |
template <> struct hash<char>;
|
|
|
|
| 5238 |
``` cpp
|
| 5239 |
transform(a.begin(), a.end(), a.begin(), negate<double>());
|
| 5240 |
```
|
| 5241 |
|
| 5242 |
To enable adaptors and other components to manipulate function objects
|
| 5243 |
+
that take one or two arguments many of the function objects in this
|
| 5244 |
+
clause correspondingly provide typedefs `argument_type` and
|
| 5245 |
+
`result_type` for function objects that take one argument and
|
| 5246 |
+
`first_argument_type`, `second_argument_type`, and `result_type` for
|
| 5247 |
+
function objects that take two arguments.
|
| 5248 |
|
| 5249 |
### Definitions <a id="func.def">[[func.def]]</a>
|
| 5250 |
|
| 5251 |
The following definitions apply to this Clause:
|
| 5252 |
|
|
|
|
| 5329 |
typedef see below second_argument_type; // not always defined
|
| 5330 |
|
| 5331 |
// construct/copy/destroy
|
| 5332 |
reference_wrapper(T&) noexcept;
|
| 5333 |
reference_wrapper(T&&) = delete; // do not bind to temporary objects
|
| 5334 |
+
reference_wrapper(const reference_wrapper& x) noexcept;
|
| 5335 |
|
| 5336 |
// assignment
|
| 5337 |
+
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 5338 |
|
| 5339 |
// access
|
| 5340 |
operator T& () const noexcept;
|
| 5341 |
T& get() const noexcept;
|
| 5342 |
|
| 5343 |
// invocation
|
| 5344 |
template <class... ArgTypes>
|
| 5345 |
+
result_of_t<T&(ArgTypes&&...)>
|
| 5346 |
operator() (ArgTypes&&...) const;
|
| 5347 |
};
|
| 5348 |
}
|
| 5349 |
```
|
| 5350 |
|
|
|
|
| 5353 |
|
| 5354 |
`reference_wrapper<T>` has a weak result type ([[func.require]]). If
|
| 5355 |
`T` is a function type, `result_type` shall be a synonym for the return
|
| 5356 |
type of `T`.
|
| 5357 |
|
| 5358 |
+
The template specialization `reference_wrapper<T>` shall define a nested
|
| 5359 |
type named `argument_type` as a synonym for `T1` only if the type `T` is
|
| 5360 |
any of the following:
|
| 5361 |
|
| 5362 |
- a function type or a pointer to function type taking one argument of
|
| 5363 |
type `T1`
|
|
|
|
| 5374 |
- a function type or a pointer to function type taking two arguments of
|
| 5375 |
types `T1` and `T2`
|
| 5376 |
- a pointer to member function `R T0::f(T2)` *cv* (where *cv* represents
|
| 5377 |
the member function’s cv-qualifiers); the type `T1` is *cv* `T0*`
|
| 5378 |
- a class type with member types `first_argument_type` and
|
| 5379 |
+
`second_argument_type`; the type `T1` is `T::first_argument_type` and
|
| 5380 |
the type `T2` is `T::second_argument_type`.
|
| 5381 |
|
| 5382 |
#### `reference_wrapper` construct/copy/destroy <a id="refwrap.const">[[refwrap.const]]</a>
|
| 5383 |
|
| 5384 |
``` cpp
|
|
|
|
| 5387 |
|
| 5388 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 5389 |
reference to `t`.
|
| 5390 |
|
| 5391 |
``` cpp
|
| 5392 |
+
reference_wrapper(const reference_wrapper& x) noexcept;
|
| 5393 |
```
|
| 5394 |
|
| 5395 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 5396 |
reference to `x.get()`.
|
| 5397 |
|
| 5398 |
#### `reference_wrapper` assignment <a id="refwrap.assign">[[refwrap.assign]]</a>
|
| 5399 |
|
| 5400 |
``` cpp
|
| 5401 |
+
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 5402 |
```
|
| 5403 |
|
| 5404 |
*Postconditions:* `*this` stores a reference to `x.get()`.
|
| 5405 |
|
| 5406 |
#### `reference_wrapper` access <a id="refwrap.access">[[refwrap.access]]</a>
|
|
|
|
| 5419 |
|
| 5420 |
#### reference_wrapper invocation <a id="refwrap.invoke">[[refwrap.invoke]]</a>
|
| 5421 |
|
| 5422 |
``` cpp
|
| 5423 |
template <class... ArgTypes>
|
| 5424 |
+
result_of_t<T&(ArgTypes&&... )>
|
| 5425 |
operator()(ArgTypes&&... args) const;
|
| 5426 |
```
|
| 5427 |
|
| 5428 |
*Returns:*
|
| 5429 |
*`INVOKE`*`(get(), std::forward<ArgTypes>(args)...)`. ([[func.require]])
|
|
|
|
| 5463 |
|
| 5464 |
The library provides basic function object classes for all of the
|
| 5465 |
arithmetic operators in the language ([[expr.mul]], [[expr.add]]).
|
| 5466 |
|
| 5467 |
``` cpp
|
| 5468 |
+
template <class T = void> struct plus {
|
| 5469 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5470 |
typedef T first_argument_type;
|
| 5471 |
typedef T second_argument_type;
|
| 5472 |
typedef T result_type;
|
| 5473 |
};
|
| 5474 |
```
|
| 5475 |
|
| 5476 |
`operator()` returns `x + y`.
|
| 5477 |
|
| 5478 |
``` cpp
|
| 5479 |
+
template <class T = void> struct minus {
|
| 5480 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5481 |
typedef T first_argument_type;
|
| 5482 |
typedef T second_argument_type;
|
| 5483 |
typedef T result_type;
|
| 5484 |
};
|
| 5485 |
```
|
| 5486 |
|
| 5487 |
`operator()` returns `x - y`.
|
| 5488 |
|
| 5489 |
``` cpp
|
| 5490 |
+
template <class T = void> struct multiplies {
|
| 5491 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5492 |
typedef T first_argument_type;
|
| 5493 |
typedef T second_argument_type;
|
| 5494 |
typedef T result_type;
|
| 5495 |
};
|
| 5496 |
```
|
| 5497 |
|
| 5498 |
`operator()` returns `x * y`.
|
| 5499 |
|
| 5500 |
``` cpp
|
| 5501 |
+
template <class T = void> struct divides {
|
| 5502 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5503 |
typedef T first_argument_type;
|
| 5504 |
typedef T second_argument_type;
|
| 5505 |
typedef T result_type;
|
| 5506 |
};
|
| 5507 |
```
|
| 5508 |
|
| 5509 |
`operator()` returns `x / y`.
|
| 5510 |
|
| 5511 |
``` cpp
|
| 5512 |
+
template <class T = void> struct modulus {
|
| 5513 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5514 |
typedef T first_argument_type;
|
| 5515 |
typedef T second_argument_type;
|
| 5516 |
typedef T result_type;
|
| 5517 |
};
|
| 5518 |
```
|
| 5519 |
|
| 5520 |
`operator()` returns `x % y`.
|
| 5521 |
|
| 5522 |
``` cpp
|
| 5523 |
+
template <class T = void> struct negate {
|
| 5524 |
+
constexpr T operator()(const T& x) const;
|
| 5525 |
typedef T argument_type;
|
| 5526 |
typedef T result_type;
|
| 5527 |
};
|
| 5528 |
```
|
| 5529 |
|
| 5530 |
`operator()` returns `-x`.
|
| 5531 |
|
| 5532 |
+
``` cpp
|
| 5533 |
+
template <> struct plus<void> {
|
| 5534 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5535 |
+
-> decltype(std::forward<T>(t) + std::forward<U>(u));
|
| 5536 |
+
|
| 5537 |
+
typedef unspecified is_transparent;
|
| 5538 |
+
};
|
| 5539 |
+
```
|
| 5540 |
+
|
| 5541 |
+
`operator()` returns `std::forward<T>(t) + std::forward<U>(u)`.
|
| 5542 |
+
|
| 5543 |
+
``` cpp
|
| 5544 |
+
template <> struct minus<void> {
|
| 5545 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5546 |
+
-> decltype(std::forward<T>(t) - std::forward<U>(u));
|
| 5547 |
+
|
| 5548 |
+
typedef unspecified is_transparent;
|
| 5549 |
+
};
|
| 5550 |
+
```
|
| 5551 |
+
|
| 5552 |
+
`operator()` returns `std::forward<T>(t) - std::forward<U>(u)`.
|
| 5553 |
+
|
| 5554 |
+
``` cpp
|
| 5555 |
+
template <> struct multiplies<void> {
|
| 5556 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5557 |
+
-> decltype(std::forward<T>(t) * std::forward<U>(u));
|
| 5558 |
+
|
| 5559 |
+
typedef unspecified is_transparent;
|
| 5560 |
+
};
|
| 5561 |
+
```
|
| 5562 |
+
|
| 5563 |
+
`operator()` returns `std::forward<T>(t) * std::forward<U>(u)`.
|
| 5564 |
+
|
| 5565 |
+
``` cpp
|
| 5566 |
+
template <> struct divides<void> {
|
| 5567 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5568 |
+
-> decltype(std::forward<T>(t) / std::forward<U>(u));
|
| 5569 |
+
|
| 5570 |
+
typedef unspecified is_transparent;
|
| 5571 |
+
};
|
| 5572 |
+
```
|
| 5573 |
+
|
| 5574 |
+
`operator()` returns `std::forward<T>(t) / std::forward<U>(u)`.
|
| 5575 |
+
|
| 5576 |
+
``` cpp
|
| 5577 |
+
template <> struct modulus<void> {
|
| 5578 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5579 |
+
-> decltype(std::forward<T>(t) % std::forward<U>(u));
|
| 5580 |
+
|
| 5581 |
+
typedef unspecified is_transparent;
|
| 5582 |
+
};
|
| 5583 |
+
```
|
| 5584 |
+
|
| 5585 |
+
`operator()` returns `std::forward<T>(t) % std::forward<U>(u)`.
|
| 5586 |
+
|
| 5587 |
+
``` cpp
|
| 5588 |
+
template <> struct negate<void> {
|
| 5589 |
+
template <class T> constexpr auto operator()(T&& t) const
|
| 5590 |
+
-> decltype(-std::forward<T>(t));
|
| 5591 |
+
|
| 5592 |
+
typedef unspecified is_transparent;
|
| 5593 |
+
};
|
| 5594 |
+
```
|
| 5595 |
+
|
| 5596 |
+
`operator()` returns `-std::forward<T>(t)`.
|
| 5597 |
+
|
| 5598 |
### Comparisons <a id="comparisons">[[comparisons]]</a>
|
| 5599 |
|
| 5600 |
The library provides basic function object classes for all of the
|
| 5601 |
comparison operators in the language ([[expr.rel]], [[expr.eq]]).
|
| 5602 |
|
| 5603 |
``` cpp
|
| 5604 |
+
template <class T = void> struct equal_to {
|
| 5605 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5606 |
typedef T first_argument_type;
|
| 5607 |
typedef T second_argument_type;
|
| 5608 |
typedef bool result_type;
|
| 5609 |
};
|
| 5610 |
```
|
| 5611 |
|
| 5612 |
`operator()` returns `x == y`.
|
| 5613 |
|
| 5614 |
``` cpp
|
| 5615 |
+
template <class T = void> struct not_equal_to {
|
| 5616 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5617 |
typedef T first_argument_type;
|
| 5618 |
typedef T second_argument_type;
|
| 5619 |
typedef bool result_type;
|
| 5620 |
};
|
| 5621 |
```
|
| 5622 |
|
| 5623 |
`operator()` returns `x != y`.
|
| 5624 |
|
| 5625 |
``` cpp
|
| 5626 |
+
template <class T = void> struct greater {
|
| 5627 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5628 |
typedef T first_argument_type;
|
| 5629 |
typedef T second_argument_type;
|
| 5630 |
typedef bool result_type;
|
| 5631 |
};
|
| 5632 |
```
|
| 5633 |
|
| 5634 |
`operator()` returns `x > y`.
|
| 5635 |
|
| 5636 |
``` cpp
|
| 5637 |
+
template <class T = void> struct less {
|
| 5638 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5639 |
typedef T first_argument_type;
|
| 5640 |
typedef T second_argument_type;
|
| 5641 |
typedef bool result_type;
|
| 5642 |
};
|
| 5643 |
```
|
| 5644 |
|
| 5645 |
`operator()` returns `x < y`.
|
| 5646 |
|
| 5647 |
``` cpp
|
| 5648 |
+
template <class T = void> struct greater_equal {
|
| 5649 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5650 |
typedef T first_argument_type;
|
| 5651 |
typedef T second_argument_type;
|
| 5652 |
typedef bool result_type;
|
| 5653 |
};
|
| 5654 |
```
|
| 5655 |
|
| 5656 |
`operator()` returns `x >= y`.
|
| 5657 |
|
| 5658 |
``` cpp
|
| 5659 |
+
template <class T = void> struct less_equal {
|
| 5660 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5661 |
typedef T first_argument_type;
|
| 5662 |
typedef T second_argument_type;
|
| 5663 |
typedef bool result_type;
|
| 5664 |
};
|
| 5665 |
```
|
| 5666 |
|
| 5667 |
`operator()` returns `x <= y`.
|
| 5668 |
|
| 5669 |
+
``` cpp
|
| 5670 |
+
template <> struct equal_to<void> {
|
| 5671 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5672 |
+
-> decltype(std::forward<T>(t) == std::forward<U>(u));
|
| 5673 |
+
|
| 5674 |
+
typedef unspecified is_transparent;
|
| 5675 |
+
};
|
| 5676 |
+
```
|
| 5677 |
+
|
| 5678 |
+
`operator()` returns `std::forward<T>(t) == std::forward<U>(u)`.
|
| 5679 |
+
|
| 5680 |
+
``` cpp
|
| 5681 |
+
template <> struct not_equal_to<void> {
|
| 5682 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5683 |
+
-> decltype(std::forward<T>(t) != std::forward<U>(u));
|
| 5684 |
+
|
| 5685 |
+
typedef unspecified is_transparent;
|
| 5686 |
+
};
|
| 5687 |
+
```
|
| 5688 |
+
|
| 5689 |
+
`operator()` returns `std::forward<T>(t) != std::forward<U>(u)`.
|
| 5690 |
+
|
| 5691 |
+
``` cpp
|
| 5692 |
+
template <> struct greater<void> {
|
| 5693 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5694 |
+
-> decltype(std::forward<T>(t) > std::forward<U>(u));
|
| 5695 |
+
|
| 5696 |
+
typedef unspecified is_transparent;
|
| 5697 |
+
};
|
| 5698 |
+
```
|
| 5699 |
+
|
| 5700 |
+
`operator()` returns `std::forward<T>(t) > std::forward<U>(u)`.
|
| 5701 |
+
|
| 5702 |
+
``` cpp
|
| 5703 |
+
template <> struct less<void> {
|
| 5704 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5705 |
+
-> decltype(std::forward<T>(t) < std::forward<U>(u));
|
| 5706 |
+
|
| 5707 |
+
typedef unspecified is_transparent;
|
| 5708 |
+
};
|
| 5709 |
+
```
|
| 5710 |
+
|
| 5711 |
+
`operator()` returns `std::forward<T>(t) < std::forward<U>(u)`.
|
| 5712 |
+
|
| 5713 |
+
``` cpp
|
| 5714 |
+
template <> struct greater_equal<void> {
|
| 5715 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5716 |
+
-> decltype(std::forward<T>(t) >= std::forward<U>(u));
|
| 5717 |
+
|
| 5718 |
+
typedef unspecified is_transparent;
|
| 5719 |
+
};
|
| 5720 |
+
```
|
| 5721 |
+
|
| 5722 |
+
`operator()` returns `std::forward<T>(t) >= std::forward<U>(u)`.
|
| 5723 |
+
|
| 5724 |
+
``` cpp
|
| 5725 |
+
template <> struct less_equal<void> {
|
| 5726 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5727 |
+
-> decltype(std::forward<T>(t) <= std::forward<U>(u));
|
| 5728 |
+
|
| 5729 |
+
typedef unspecified is_transparent;
|
| 5730 |
+
};
|
| 5731 |
+
```
|
| 5732 |
+
|
| 5733 |
+
`operator()` returns `std::forward<T>(t) <= std::forward<U>(u)`.
|
| 5734 |
+
|
| 5735 |
For templates `greater`, `less`, `greater_equal`, and `less_equal`, the
|
| 5736 |
specializations for any pointer type yield a total order, even if the
|
| 5737 |
built-in operators `<`, `>`, `<=`, `>=` do not.
|
| 5738 |
|
| 5739 |
### Logical operations <a id="logical.operations">[[logical.operations]]</a>
|
|
|
|
| 5741 |
The library provides basic function object classes for all of the
|
| 5742 |
logical operators in the language ([[expr.log.and]], [[expr.log.or]],
|
| 5743 |
[[expr.unary.op]]).
|
| 5744 |
|
| 5745 |
``` cpp
|
| 5746 |
+
template <class T = void> struct logical_and {
|
| 5747 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5748 |
typedef T first_argument_type;
|
| 5749 |
typedef T second_argument_type;
|
| 5750 |
typedef bool result_type;
|
| 5751 |
};
|
| 5752 |
```
|
| 5753 |
|
| 5754 |
`operator()` returns `x && y`.
|
| 5755 |
|
| 5756 |
``` cpp
|
| 5757 |
+
template <class T = void> struct logical_or {
|
| 5758 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 5759 |
typedef T first_argument_type;
|
| 5760 |
typedef T second_argument_type;
|
| 5761 |
typedef bool result_type;
|
| 5762 |
};
|
| 5763 |
```
|
| 5764 |
|
| 5765 |
`operator()` returns `x || y`.
|
| 5766 |
|
| 5767 |
``` cpp
|
| 5768 |
+
template <class T = void> struct logical_not {
|
| 5769 |
+
constexpr bool operator()(const T& x) const;
|
| 5770 |
typedef T argument_type;
|
| 5771 |
typedef bool result_type;
|
| 5772 |
};
|
| 5773 |
```
|
| 5774 |
|
| 5775 |
`operator()` returns `!x`.
|
| 5776 |
|
| 5777 |
+
``` cpp
|
| 5778 |
+
template <> struct logical_and<void> {
|
| 5779 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5780 |
+
-> decltype(std::forward<T>(t) && std::forward<U>(u));
|
| 5781 |
+
|
| 5782 |
+
typedef unspecified is_transparent;
|
| 5783 |
+
};
|
| 5784 |
+
```
|
| 5785 |
+
|
| 5786 |
+
`operator()` returns `std::forward<T>(t) && std::forward<U>(u)`.
|
| 5787 |
+
|
| 5788 |
+
``` cpp
|
| 5789 |
+
template <> struct logical_or<void> {
|
| 5790 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5791 |
+
-> decltype(std::forward<T>(t) || std::forward<U>(u));
|
| 5792 |
+
|
| 5793 |
+
typedef unspecified is_transparent;
|
| 5794 |
+
};
|
| 5795 |
+
```
|
| 5796 |
+
|
| 5797 |
+
`operator()` returns `std::forward<T>(t) || std::forward<U>(u)`.
|
| 5798 |
+
|
| 5799 |
+
``` cpp
|
| 5800 |
+
template <> struct logical_not<void> {
|
| 5801 |
+
template <class T> constexpr auto operator()(T&& t) const
|
| 5802 |
+
-> decltype(!std::forward<T>(t));
|
| 5803 |
+
|
| 5804 |
+
typedef unspecified is_transparent;
|
| 5805 |
+
};
|
| 5806 |
+
```
|
| 5807 |
+
|
| 5808 |
+
`operator()` returns `!std::forward<T>(t)`.
|
| 5809 |
+
|
| 5810 |
### Bitwise operations <a id="bitwise.operations">[[bitwise.operations]]</a>
|
| 5811 |
|
| 5812 |
The library provides basic function object classes for all of the
|
| 5813 |
bitwise operators in the language ([[expr.bit.and]], [[expr.or]],
|
| 5814 |
+
[[expr.xor]], [[expr.unary.op]]).
|
| 5815 |
|
| 5816 |
``` cpp
|
| 5817 |
+
template <class T = void> struct bit_and {
|
| 5818 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5819 |
typedef T first_argument_type;
|
| 5820 |
typedef T second_argument_type;
|
| 5821 |
typedef T result_type;
|
| 5822 |
};
|
| 5823 |
```
|
| 5824 |
|
| 5825 |
`operator()` returns `x & y`.
|
| 5826 |
|
| 5827 |
``` cpp
|
| 5828 |
+
template <class T = void> struct bit_or {
|
| 5829 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5830 |
typedef T first_argument_type;
|
| 5831 |
typedef T second_argument_type;
|
| 5832 |
typedef T result_type;
|
| 5833 |
};
|
| 5834 |
```
|
| 5835 |
|
| 5836 |
`operator()` returns `x | y`.
|
| 5837 |
|
| 5838 |
``` cpp
|
| 5839 |
+
template <class T = void> struct bit_xor {
|
| 5840 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 5841 |
typedef T first_argument_type;
|
| 5842 |
typedef T second_argument_type;
|
| 5843 |
typedef T result_type;
|
| 5844 |
};
|
| 5845 |
```
|
| 5846 |
|
| 5847 |
`operator()` returns `x ^ y`.
|
| 5848 |
|
| 5849 |
+
``` cpp
|
| 5850 |
+
template <class T = void> struct bit_not {
|
| 5851 |
+
constexpr T operator()(const T& x) const;
|
| 5852 |
+
typedef T argument_type;
|
| 5853 |
+
typedef T result_type;
|
| 5854 |
+
};
|
| 5855 |
+
```
|
| 5856 |
+
|
| 5857 |
+
`operator()` returns `~x`.
|
| 5858 |
+
|
| 5859 |
+
``` cpp
|
| 5860 |
+
template <> struct bit_and<void> {
|
| 5861 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5862 |
+
-> decltype(std::forward<T>(t) & std::forward<U>(u));
|
| 5863 |
+
|
| 5864 |
+
typedef unspecified is_transparent;
|
| 5865 |
+
};
|
| 5866 |
+
```
|
| 5867 |
+
|
| 5868 |
+
`operator()` returns `std::forward<T>(t) & std::forward<U>(u)`.
|
| 5869 |
+
|
| 5870 |
+
``` cpp
|
| 5871 |
+
template <> struct bit_or<void> {
|
| 5872 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5873 |
+
-> decltype(std::forward<T>(t) | std::forward<U>(u));
|
| 5874 |
+
|
| 5875 |
+
typedef unspecified is_transparent;
|
| 5876 |
+
};
|
| 5877 |
+
```
|
| 5878 |
+
|
| 5879 |
+
`operator()` returns `std::forward<T>(t) | std::forward<U>(u)`.
|
| 5880 |
+
|
| 5881 |
+
``` cpp
|
| 5882 |
+
template <> struct bit_xor<void> {
|
| 5883 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 5884 |
+
-> decltype(std::forward<T>(t) ^ std::forward<U>(u));
|
| 5885 |
+
|
| 5886 |
+
typedef unspecified is_transparent;
|
| 5887 |
+
};
|
| 5888 |
+
```
|
| 5889 |
+
|
| 5890 |
+
`operator()` returns `std::forward<T>(t) ^ std::forward<U>(u)`.
|
| 5891 |
+
|
| 5892 |
+
``` cpp
|
| 5893 |
+
template <> struct bit_not<void> {
|
| 5894 |
+
template <class T> constexpr auto operator()(T&& t) const
|
| 5895 |
+
-> decltype(~std::forward<T>(t));
|
| 5896 |
+
|
| 5897 |
+
typedef unspecified is_transparent;
|
| 5898 |
+
};
|
| 5899 |
+
```
|
| 5900 |
+
|
| 5901 |
+
`operator()` returns `~std::forward<T>(t)`.
|
| 5902 |
+
|
| 5903 |
### Negators <a id="negators">[[negators]]</a>
|
| 5904 |
|
| 5905 |
Negators `not1` and `not2` take a unary and a binary predicate,
|
| 5906 |
respectively, and return their complements ([[expr.unary.op]]).
|
| 5907 |
|
| 5908 |
``` cpp
|
| 5909 |
template <class Predicate>
|
| 5910 |
class unary_negate {
|
| 5911 |
public:
|
| 5912 |
+
constexpr explicit unary_negate(const Predicate& pred);
|
| 5913 |
+
constexpr bool operator()(const typename Predicate::argument_type& x) const;
|
| 5914 |
typedef typename Predicate::argument_type argument_type;
|
| 5915 |
typedef bool result_type;
|
| 5916 |
};
|
| 5917 |
```
|
| 5918 |
|
| 5919 |
`operator()` returns `!pred(x)`.
|
| 5920 |
|
| 5921 |
``` cpp
|
| 5922 |
template <class Predicate>
|
| 5923 |
+
constexpr unary_negate<Predicate> not1(const Predicate& pred);
|
| 5924 |
```
|
| 5925 |
|
| 5926 |
*Returns:* `unary_negate<Predicate>(pred)`.
|
| 5927 |
|
| 5928 |
``` cpp
|
| 5929 |
template <class Predicate>
|
| 5930 |
class binary_negate {
|
| 5931 |
public:
|
| 5932 |
+
constexpr explicit binary_negate(const Predicate& pred);
|
| 5933 |
+
constexpr bool operator()(const typename Predicate::first_argument_type& x,
|
| 5934 |
const typename Predicate::second_argument_type& y) const;
|
| 5935 |
typedef typename Predicate::first_argument_type first_argument_type;
|
| 5936 |
typedef typename Predicate::second_argument_type second_argument_type;
|
| 5937 |
typedef bool result_type;
|
| 5938 |
};
|
|
|
|
| 5940 |
|
| 5941 |
`operator()` returns `!pred(x,y)`.
|
| 5942 |
|
| 5943 |
``` cpp
|
| 5944 |
template <class Predicate>
|
| 5945 |
+
constexpr binary_negate<Predicate> not2(const Predicate& pred);
|
| 5946 |
```
|
| 5947 |
|
| 5948 |
*Returns:* `binary_negate<Predicate>(pred)`.
|
| 5949 |
|
| 5950 |
+
### Function object binders <a id="func.bind">[[func.bind]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5951 |
|
| 5952 |
This subclause describes a uniform mechanism for binding arguments of
|
| 5953 |
callable objects.
|
| 5954 |
|
| 5955 |
+
#### Class template `is_bind_expression` <a id="func.bind.isbind">[[func.bind.isbind]]</a>
|
| 5956 |
|
| 5957 |
``` cpp
|
| 5958 |
namespace std {
|
| 5959 |
+
template<class T> struct is_bind_expression; // see below
|
|
|
|
| 5960 |
}
|
| 5961 |
```
|
| 5962 |
|
| 5963 |
`is_bind_expression` can be used to detect function objects generated by
|
| 5964 |
+
`bind`. `bind` uses `is_bind_expression` to detect subexpressions.
|
|
|
|
|
|
|
| 5965 |
|
| 5966 |
+
Instantiations of the `is_bind_expression` template shall meet the
|
| 5967 |
+
UnaryTypeTrait requirements ([[meta.rqmts]]). The implementation shall
|
| 5968 |
+
provide a definition that has a BaseCharacteristic of `true_type` if `T`
|
| 5969 |
+
is a type returned from `bind`, otherwise it shall have a
|
| 5970 |
+
BaseCharacteristic of `false_type`. A program may specialize this
|
| 5971 |
+
template for a user-defined type `T` to have a BaseCharacteristic of
|
| 5972 |
+
`true_type` to indicate that `T` should be treated as a subexpression in
|
| 5973 |
+
a `bind` call.
|
| 5974 |
+
|
| 5975 |
+
#### Class template `is_placeholder` <a id="func.bind.isplace">[[func.bind.isplace]]</a>
|
| 5976 |
+
|
| 5977 |
+
``` cpp
|
| 5978 |
+
namespace std {
|
| 5979 |
+
template<class T> struct is_placeholder; // see below
|
| 5980 |
+
}
|
| 5981 |
+
```
|
| 5982 |
|
| 5983 |
`is_placeholder` can be used to detect the standard placeholders `_1`,
|
| 5984 |
`_2`, and so on. `bind` uses `is_placeholder` to detect placeholders.
|
|
|
|
| 5985 |
|
| 5986 |
+
Instantiations of the `is_placeholder` template shall meet the
|
| 5987 |
+
UnaryTypeTrait requirements ([[meta.rqmts]]). The implementation shall
|
| 5988 |
+
provide a definition that has the BaseCharacteristic of
|
| 5989 |
+
`integral_constant<int, J>` if `T` is the type of
|
| 5990 |
+
`std::placeholders::_J`, otherwise it shall have a BaseCharacteristic of
|
| 5991 |
+
`integral_constant<int, 0>`. A program may specialize this template for
|
| 5992 |
+
a user-defined type `T` to have a BaseCharacteristic of
|
| 5993 |
+
`integral_constant<int, N>` with `N > 0` to indicate that `T` should be
|
| 5994 |
+
treated as a placeholder type.
|
| 5995 |
|
| 5996 |
+
#### Function template `bind` <a id="func.bind.bind">[[func.bind.bind]]</a>
|
| 5997 |
|
| 5998 |
In the text that follows, the following names have the following
|
| 5999 |
meanings:
|
| 6000 |
|
| 6001 |
+
- `FD` is the type `decay_t<F>`,
|
| 6002 |
- `fd` is an lvalue of type `FD` constructed from `std::forward<F>(f)`,
|
| 6003 |
+
- `Ti` is the iᵗʰ type in the template parameter pack `BoundArgs`,
|
| 6004 |
+
- `TiD` is the type `decay_t<Ti>`,
|
| 6005 |
- `ti` is the iᵗʰ argument in the function parameter pack `bound_args`,
|
| 6006 |
- `tid` is an lvalue of type `TiD` constructed from
|
| 6007 |
`std::forward<Ti>(ti)`,
|
| 6008 |
- `Uj` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
|
| 6009 |
the forwarding call wrapper, and
|
|
|
|
| 6020 |
expression for some values *w1, w2, ..., wN*, where
|
| 6021 |
`N == sizeof...(bound_args)`.
|
| 6022 |
|
| 6023 |
*Returns:* A forwarding call wrapper `g` with a weak result
|
| 6024 |
type ([[func.require]]). The effect of `g(u1, u2, ..., uM)` shall be
|
| 6025 |
+
*`INVOKE`*`(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), result_of_t<FD `*`cv`*` & (V1, V2, ..., VN)>)`,
|
| 6026 |
where *`cv`* represents the *cv*-qualifiers of `g` and the values and
|
| 6027 |
types of the bound arguments `v1, v2, ..., vN` are determined as
|
| 6028 |
specified below. The copy constructor and move constructor of the
|
| 6029 |
forwarding call wrapper shall throw an exception if and only if the
|
| 6030 |
corresponding constructor of `FD` or of any of the types `TiD` throws an
|
|
|
|
| 6049 |
*`INVOKE`*`(fd, w1, w2, ..., wN)` shall be a valid expression for some
|
| 6050 |
values *w1, w2, ..., wN*, where `N == sizeof...(bound_args)`.
|
| 6051 |
|
| 6052 |
*Returns:* A forwarding call wrapper `g` with a nested type
|
| 6053 |
`result_type` defined as a synonym for `R`. The effect of
|
| 6054 |
+
`g(u1, u2, ..., uM)` shall be
|
| 6055 |
+
*`INVOKE`*`(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), R)`,
|
| 6056 |
where the values and types of the bound arguments `v1, v2, ..., vN` are
|
| 6057 |
determined as specified below. The copy constructor and move constructor
|
| 6058 |
of the forwarding call wrapper shall throw an exception if and only if
|
| 6059 |
the corresponding constructor of `FD` or of any of the types `TiD`
|
| 6060 |
throws an exception.
|
|
|
|
| 6075 |
|
| 6076 |
- if `TiD` is `reference_wrapper<T>`, the argument is `tid.get()` and
|
| 6077 |
its type `Vi` is `T&`;
|
| 6078 |
- if the value of `is_bind_expression<TiD>::value` is `true`, the
|
| 6079 |
argument is `tid(std::forward<Uj>({}uj)...)` and its type `Vi` is
|
| 6080 |
+
`result_of_t<TiD cv & (Uj&&...)>&&`;
|
| 6081 |
- if the value `j` of `is_placeholder<TiD>::value` is not zero, the
|
| 6082 |
argument is `std::forward<Uj>(uj)` and its type `Vi` is `Uj&&`;
|
| 6083 |
- otherwise, the value is `tid` and its type `Vi` is `TiD cv &`.
|
| 6084 |
|
| 6085 |
+
#### Placeholders <a id="func.bind.place">[[func.bind.place]]</a>
|
| 6086 |
|
| 6087 |
``` cpp
|
| 6088 |
namespace std {
|
| 6089 |
namespace placeholders {
|
| 6090 |
// M is the implementation-defined number of placeholders
|
|
|
|
| 6105 |
placeholders’ copy assignment operators shall not throw exceptions.
|
| 6106 |
|
| 6107 |
### Function template `mem_fn` <a id="func.memfn">[[func.memfn]]</a>
|
| 6108 |
|
| 6109 |
``` cpp
|
| 6110 |
+
template<class R, class T> unspecified mem_fn(R T::* pm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6111 |
```
|
| 6112 |
|
| 6113 |
*Returns:* A simple call wrapper ([[func.def]]) `fn` such that the
|
| 6114 |
expression `fn(t, a2, ..., aN)` is equivalent to
|
| 6115 |
*`INVOKE`*`(pm, t, a2, ..., aN)` ([[func.require]]). `fn` shall have a
|
|
|
|
| 6167 |
|
| 6168 |
template<class R, class... ArgTypes>
|
| 6169 |
class function<R(ArgTypes...)> {
|
| 6170 |
public:
|
| 6171 |
typedef R result_type;
|
| 6172 |
+
typedef T1 argument_type; // only if sizeof...(ArgTypes) == 1 and
|
| 6173 |
// the type in ArgTypes is T1
|
| 6174 |
+
typedef T1 first_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 6175 |
// ArgTypes contains T1 and T2
|
| 6176 |
+
typedef T2 second_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 6177 |
// ArgTypes contains T1 and T2
|
| 6178 |
|
| 6179 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 6180 |
function() noexcept;
|
| 6181 |
function(nullptr_t) noexcept;
|
|
|
|
| 6209 |
// [func.wrap.func.inv], function invocation:
|
| 6210 |
R operator()(ArgTypes...) const;
|
| 6211 |
|
| 6212 |
// [func.wrap.func.targ], function target access:
|
| 6213 |
const std::type_info& target_type() const noexcept;
|
| 6214 |
+
template<class T> T* target() noexcept;
|
| 6215 |
+
template<class T> const T* target() const noexcept;
|
| 6216 |
|
| 6217 |
};
|
| 6218 |
|
| 6219 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 6220 |
template <class R, class... ArgTypes>
|
|
|
|
| 6303 |
``` cpp
|
| 6304 |
template<class F> function(F f);
|
| 6305 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 6306 |
```
|
| 6307 |
|
| 6308 |
+
*Requires:* `F` shall be `CopyConstructible`.
|
| 6309 |
+
|
| 6310 |
+
*Remarks:* These constructors shall not participate in overload
|
| 6311 |
+
resolution unless `f` is Callable ([[func.wrap.func]]) for argument
|
| 6312 |
+
types `ArgTypes...` and return type `R`.
|
| 6313 |
|
| 6314 |
*Postconditions:* `!*this` if any of the following hold:
|
| 6315 |
|
| 6316 |
+
- `f` is a null function pointer value.
|
| 6317 |
+
- `f` is a null member pointer value.
|
| 6318 |
+
- `F` is an instance of the `function` class template, and `!f`.
|
| 6319 |
|
| 6320 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 6321 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 6322 |
dynamically allocated memory for small callable objects, for example,
|
| 6323 |
where `f`’s target is an object holding only a pointer or reference to
|
|
|
|
| 6345 |
|
| 6346 |
``` cpp
|
| 6347 |
function& operator=(nullptr_t);
|
| 6348 |
```
|
| 6349 |
|
| 6350 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 6351 |
|
| 6352 |
*Postconditions:* `!(*this)`.
|
| 6353 |
|
| 6354 |
*Returns:* `*this`
|
| 6355 |
|
|
|
|
| 6359 |
|
| 6360 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 6361 |
|
| 6362 |
*Returns:* `*this`
|
| 6363 |
|
| 6364 |
+
*Remarks:* This assignment operator shall not participate in overload
|
| 6365 |
+
resolution unless `declval<typename decay<F>::type&>()` is
|
| 6366 |
+
Callable ([[func.wrap.func]]) for argument types `ArgTypes...` and
|
| 6367 |
+
return type `R`.
|
| 6368 |
+
|
| 6369 |
``` cpp
|
| 6370 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 6371 |
```
|
| 6372 |
|
| 6373 |
*Effects:* `function(f).swap(*this);`
|
|
|
|
| 6376 |
|
| 6377 |
``` cpp
|
| 6378 |
~function();
|
| 6379 |
```
|
| 6380 |
|
| 6381 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 6382 |
|
| 6383 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 6384 |
|
| 6385 |
``` cpp
|
| 6386 |
void swap(function& other) noexcept;
|
|
|
|
| 6427 |
|
| 6428 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 6429 |
`typeid(void)`.
|
| 6430 |
|
| 6431 |
``` cpp
|
| 6432 |
+
template<class T> T* target() noexcept;
|
| 6433 |
+
template<class T> const T* target() const noexcept;
|
| 6434 |
```
|
| 6435 |
|
| 6436 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 6437 |
for parameter types `ArgTypes` and return type `R`.
|
| 6438 |
|
| 6439 |
+
*Returns:* If `target_type() == typeid(T)` a pointer to the stored
|
| 6440 |
function target; otherwise a null pointer.
|
| 6441 |
|
| 6442 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 6443 |
|
| 6444 |
``` cpp
|
|
|
|
| 6471 |
### Class template `hash` <a id="unord.hash">[[unord.hash]]</a>
|
| 6472 |
|
| 6473 |
The unordered associative containers defined in [[unord]] use
|
| 6474 |
specializations of the class template `hash` as the default hash
|
| 6475 |
function. For all object types `Key` for which there exists a
|
| 6476 |
+
specialization `hash<Key>`, and for all enumeration types (
|
| 6477 |
+
[[dcl.enum]]) `Key`, the instantiation `hash<Key>` shall:
|
| 6478 |
|
| 6479 |
- satisfy the `Hash` requirements ([[hash.requirements]]), with `Key`
|
| 6480 |
as the function call argument type, the `DefaultConstructible`
|
| 6481 |
requirements (Table [[defaultconstructible]]), the `CopyAssignable`
|
| 6482 |
requirements (Table [[copyassignable]]),
|
|
|
|
| 6511 |
template <> struct hash<double>;
|
| 6512 |
template <> struct hash<long double>;
|
| 6513 |
template <class T> struct hash<T*>;
|
| 6514 |
```
|
| 6515 |
|
| 6516 |
+
The template specializations shall meet the requirements of class
|
| 6517 |
+
template `hash` ([[unord.hash]]).
|
| 6518 |
|
| 6519 |
## Metaprogramming and type traits <a id="meta">[[meta]]</a>
|
| 6520 |
|
| 6521 |
This subclause describes components used by C++programs, particularly in
|
| 6522 |
templates, to support the widest possible range of types, optimise
|
|
|
|
| 6557 |
BinaryTypeTrait.
|
| 6558 |
|
| 6559 |
A *TransformationTrait* modifies a property of a type. It shall be a
|
| 6560 |
class template that takes one template type argument and, optionally,
|
| 6561 |
additional arguments that help define the modification. It shall define
|
| 6562 |
+
a publicly accessible nested type named `type`, which shall be a synonym
|
| 6563 |
+
for the modified type.
|
| 6564 |
|
| 6565 |
### Header `<type_traits>` synopsis <a id="meta.type.synop">[[meta.type.synop]]</a>
|
| 6566 |
|
| 6567 |
``` cpp
|
| 6568 |
namespace std {
|
|
|
|
| 6571 |
typedef integral_constant<bool, true> true_type;
|
| 6572 |
typedef integral_constant<bool, false> false_type;
|
| 6573 |
|
| 6574 |
// [meta.unary.cat], primary type categories:
|
| 6575 |
template <class T> struct is_void;
|
| 6576 |
+
template <class T> struct is_null_pointer;
|
| 6577 |
template <class T> struct is_integral;
|
| 6578 |
template <class T> struct is_floating_point;
|
| 6579 |
template <class T> struct is_array;
|
| 6580 |
template <class T> struct is_pointer;
|
| 6581 |
template <class T> struct is_lvalue_reference;
|
|
|
|
| 6605 |
template <class T> struct is_pod;
|
| 6606 |
template <class T> struct is_literal_type;
|
| 6607 |
template <class T> struct is_empty;
|
| 6608 |
template <class T> struct is_polymorphic;
|
| 6609 |
template <class T> struct is_abstract;
|
| 6610 |
+
template <class T> struct is_final;
|
| 6611 |
|
| 6612 |
template <class T> struct is_signed;
|
| 6613 |
template <class T> struct is_unsigned;
|
| 6614 |
|
| 6615 |
template <class T, class... Args> struct is_constructible;
|
|
|
|
| 6661 |
template <class T> struct remove_cv;
|
| 6662 |
template <class T> struct add_const;
|
| 6663 |
template <class T> struct add_volatile;
|
| 6664 |
template <class T> struct add_cv;
|
| 6665 |
|
| 6666 |
+
template <class T>
|
| 6667 |
+
using remove_const_t = typename remove_const<T>::type;
|
| 6668 |
+
template <class T>
|
| 6669 |
+
using remove_volatile_t = typename remove_volatile<T>::type;
|
| 6670 |
+
template <class T>
|
| 6671 |
+
using remove_cv_t = typename remove_cv<T>::type;
|
| 6672 |
+
template <class T>
|
| 6673 |
+
using add_const_t = typename add_const<T>::type;
|
| 6674 |
+
template <class T>
|
| 6675 |
+
using add_volatile_t = typename add_volatile<T>::type;
|
| 6676 |
+
template <class T>
|
| 6677 |
+
using add_cv_t = typename add_cv<T>::type;
|
| 6678 |
+
|
| 6679 |
// [meta.trans.ref], reference modifications:
|
| 6680 |
template <class T> struct remove_reference;
|
| 6681 |
template <class T> struct add_lvalue_reference;
|
| 6682 |
template <class T> struct add_rvalue_reference;
|
| 6683 |
|
| 6684 |
+
template <class T>
|
| 6685 |
+
using remove_reference_t = typename remove_reference<T>::type;
|
| 6686 |
+
template <class T>
|
| 6687 |
+
using add_lvalue_reference_t = typename add_lvalue_reference<T>::type;
|
| 6688 |
+
template <class T>
|
| 6689 |
+
using add_rvalue_reference_t = typename add_rvalue_reference<T>::type;
|
| 6690 |
+
|
| 6691 |
// [meta.trans.sign], sign modifications:
|
| 6692 |
template <class T> struct make_signed;
|
| 6693 |
template <class T> struct make_unsigned;
|
| 6694 |
|
| 6695 |
+
template <class T>
|
| 6696 |
+
using make_signed_t = typename make_signed<T>::type;
|
| 6697 |
+
template <class T>
|
| 6698 |
+
using make_unsigned_t = typename make_unsigned<T>::type;
|
| 6699 |
+
|
| 6700 |
// [meta.trans.arr], array modifications:
|
| 6701 |
template <class T> struct remove_extent;
|
| 6702 |
template <class T> struct remove_all_extents;
|
| 6703 |
|
| 6704 |
+
template <class T>
|
| 6705 |
+
using remove_extent_t = typename remove_extent<T>::type;
|
| 6706 |
+
template <class T>
|
| 6707 |
+
using remove_all_extents_t = typename remove_all_extents<T>::type;
|
| 6708 |
+
|
| 6709 |
// [meta.trans.ptr], pointer modifications:
|
| 6710 |
template <class T> struct remove_pointer;
|
| 6711 |
template <class T> struct add_pointer;
|
| 6712 |
|
| 6713 |
+
template <class T>
|
| 6714 |
+
using remove_pointer_t = typename remove_pointer<T>::type;
|
| 6715 |
+
template <class T>
|
| 6716 |
+
using add_pointer_t = typename add_pointer<T>::type;
|
| 6717 |
+
|
| 6718 |
// [meta.trans.other], other transformations:
|
| 6719 |
template <std::size_t Len,
|
| 6720 |
std::size_t Align = default-alignment> // see [meta.trans.other]
|
| 6721 |
struct aligned_storage;
|
| 6722 |
template <std::size_t Len, class... Types> struct aligned_union;
|
|
|
|
| 6725 |
template <bool, class T, class F> struct conditional;
|
| 6726 |
template <class... T> struct common_type;
|
| 6727 |
template <class T> struct underlying_type;
|
| 6728 |
template <class> class result_of; // not defined
|
| 6729 |
template <class F, class... ArgTypes> class result_of<F(ArgTypes...)>;
|
| 6730 |
+
|
| 6731 |
+
template <std::size_t Len,
|
| 6732 |
+
std::size_t Align = default-alignment > // see [meta.trans.other]
|
| 6733 |
+
using aligned_storage_t = typename aligned_storage<Len,Align>::type;
|
| 6734 |
+
template <std::size_t Len, class... Types>
|
| 6735 |
+
using aligned_union_t = typename aligned_union<Len,Types...>::type;
|
| 6736 |
+
template <class T>
|
| 6737 |
+
using decay_t = typename decay<T>::type;
|
| 6738 |
+
template <bool b, class T = void>
|
| 6739 |
+
using enable_if_t = typename enable_if<b,T>::type;
|
| 6740 |
+
template <bool b, class T, class F>
|
| 6741 |
+
using conditional_t = typename conditional<b,T,F>::type;
|
| 6742 |
+
template <class... T>
|
| 6743 |
+
using common_type_t = typename common_type<T...>::type;
|
| 6744 |
+
template <class T>
|
| 6745 |
+
using underlying_type_t = typename underlying_type<T>::type;
|
| 6746 |
+
template <class T>
|
| 6747 |
+
using result_of_t = typename result_of<T>::type;
|
| 6748 |
} // namespace std
|
| 6749 |
```
|
| 6750 |
|
| 6751 |
The behavior of a program that adds specializations for any of the class
|
| 6752 |
templates defined in this subclause is undefined unless otherwise
|
|
|
|
| 6759 |
template <class T, T v>
|
| 6760 |
struct integral_constant {
|
| 6761 |
static constexpr T value = v;
|
| 6762 |
typedef T value_type;
|
| 6763 |
typedef integral_constant<T,v> type;
|
| 6764 |
+
constexpr operator value_type() const noexcept { return value; }
|
| 6765 |
+
constexpr value_type operator()() const noexcept { return value; }
|
| 6766 |
};
|
| 6767 |
typedef integral_constant<bool, true> true_type;
|
| 6768 |
typedef integral_constant<bool, false> false_type;
|
| 6769 |
}
|
| 6770 |
```
|
|
|
|
| 6823 |
is_const<int[3]>::value // false
|
| 6824 |
is_const<const int[3]>::value // true
|
| 6825 |
```
|
| 6826 |
|
| 6827 |
``` cpp
|
| 6828 |
+
remove_const_t<const volatile int> // volatile int
|
| 6829 |
+
remove_const_t<const int* const> // const int*
|
| 6830 |
+
remove_const_t<const int&> // const int&
|
| 6831 |
+
remove_const_t<const int[3]> // int[3]
|
| 6832 |
+
```
|
| 6833 |
+
|
| 6834 |
+
``` cpp
|
| 6835 |
+
// Given:
|
| 6836 |
+
struct P final { };
|
| 6837 |
+
union U1 { };
|
| 6838 |
+
union U2 final { };
|
| 6839 |
+
|
| 6840 |
+
// the following assertions hold:
|
| 6841 |
+
static_assert(!is_final<int>::value, "Error!");
|
| 6842 |
+
static_assert( is_final<P>::value, "Error!");
|
| 6843 |
+
static_assert(!is_final<U1>::value, "Error!");
|
| 6844 |
+
static_assert( is_final<U2>::value, "Error!");
|
| 6845 |
```
|
| 6846 |
|
| 6847 |
Given the following function prototype:
|
| 6848 |
|
| 6849 |
``` cpp
|
| 6850 |
template <class T>
|
| 6851 |
+
add_rvalue_reference_t<T> create() noexcept;
|
| 6852 |
```
|
| 6853 |
|
| 6854 |
the predicate condition for a template specialization
|
| 6855 |
`is_constructible<T, Args...>` shall be satisfied if and only if the
|
| 6856 |
following variable definition would be well-formed for some invented
|
|
|
|
| 6872 |
### Type property queries <a id="meta.unary.prop.query">[[meta.unary.prop.query]]</a>
|
| 6873 |
|
| 6874 |
This sub-clause contains templates that may be used to query properties
|
| 6875 |
of types at compile time.
|
| 6876 |
|
| 6877 |
+
Each of these templates shall be a `UnaryTypeTrait` ([[meta.rqmts]])
|
| 6878 |
+
with a `BaseCharacteristic` of `integral_constant<size_t, Value>`.
|
| 6879 |
+
|
| 6880 |
``` cpp
|
| 6881 |
// the following assertions hold:
|
| 6882 |
assert(rank<int>::value == 0);
|
| 6883 |
assert(rank<int[2]>::value == 1);
|
| 6884 |
assert(rank<int[][4]>::value == 2);
|
|
|
|
| 6923 |
|
| 6924 |
Given the following function prototype:
|
| 6925 |
|
| 6926 |
``` cpp
|
| 6927 |
template <class T>
|
| 6928 |
+
add_rvalue_reference_t<T> create() noexcept;
|
| 6929 |
```
|
| 6930 |
|
| 6931 |
the predicate condition for a template specialization
|
| 6932 |
`is_convertible<From, To>` shall be satisfied if and only if the return
|
| 6933 |
expression in the following code would be well-formed, including any
|
|
|
|
| 6966 |
|
| 6967 |
#### Array modifications <a id="meta.trans.arr">[[meta.trans.arr]]</a>
|
| 6968 |
|
| 6969 |
``` cpp
|
| 6970 |
// the following assertions hold:
|
| 6971 |
+
assert((is_same<remove_extent_t<int>, int>::value));
|
| 6972 |
+
assert((is_same<remove_extent_t<int[2]>, int>::value));
|
| 6973 |
+
assert((is_same<remove_extent_t<int[2][3]>, int[3]>::value));
|
| 6974 |
+
assert((is_same<remove_extent_t<int[][3]>, int[3]>::value));
|
| 6975 |
```
|
| 6976 |
|
| 6977 |
``` cpp
|
| 6978 |
// the following assertions hold:
|
| 6979 |
+
assert((is_same<remove_all_extents_t<int>, int>::value));
|
| 6980 |
+
assert((is_same<remove_all_extents_t<int[2]>, int>::value));
|
| 6981 |
+
assert((is_same<remove_all_extents_t<int[2][3]>, int>::value));
|
| 6982 |
+
assert((is_same<remove_all_extents_t<int[][3]>, int>::value));
|
| 6983 |
```
|
| 6984 |
|
| 6985 |
#### Pointer modifications <a id="meta.trans.ptr">[[meta.trans.ptr]]</a>
|
| 6986 |
|
| 6987 |
#### Other transformations <a id="meta.trans.other">[[meta.trans.other]]</a>
|
|
|
|
| 7005 |
``` cpp
|
| 7006 |
template <class ...T> struct common_type;
|
| 7007 |
|
| 7008 |
template <class T>
|
| 7009 |
struct common_type<T> {
|
| 7010 |
+
typedef decay_t<T> type;
|
| 7011 |
};
|
| 7012 |
|
| 7013 |
template <class T, class U>
|
| 7014 |
struct common_type<T, U> {
|
| 7015 |
+
typedef decay_t<decltype(true ? declval<T>() : declval<U>())> type;
|
| 7016 |
};
|
| 7017 |
|
| 7018 |
template <class T, class U, class... V>
|
| 7019 |
struct common_type<T, U, V...> {
|
| 7020 |
+
typedef common_type_t<common_type_t<T, U>, V...> type;
|
| 7021 |
};
|
| 7022 |
```
|
| 7023 |
|
| 7024 |
Given these definitions:
|
| 7025 |
|
|
|
|
| 7039 |
```
|
| 7040 |
|
| 7041 |
the following assertions will hold:
|
| 7042 |
|
| 7043 |
``` cpp
|
| 7044 |
+
static_assert(is_same<result_of_t<S(int)>, short>::value, "Error!");
|
| 7045 |
+
static_assert(is_same<result_of_t<S&(unsigned char, int&)>, double>::value, "Error!");
|
| 7046 |
+
static_assert(is_same<result_of_t<PF1()>, bool>::value, "Error!");
|
| 7047 |
+
static_assert(is_same<result_of_t<PMF(unique_ptr<S>, int)>, void>::value, "Error!");
|
| 7048 |
+
static_assert(is_same<result_of_t<PMD(S)>, char&&>::value, "Error!");
|
| 7049 |
+
static_assert(is_same<result_of_t<PMD(const S*)>, const char&>::value, "Error!");
|
| 7050 |
```
|
| 7051 |
|
| 7052 |
## Compile-time rational arithmetic <a id="ratio">[[ratio]]</a>
|
| 7053 |
|
| 7054 |
### In general <a id="ratio.general">[[ratio.general]]</a>
|
|
|
|
| 7056 |
This subclause describes the ratio library. It provides a class template
|
| 7057 |
`ratio` which exactly represents any finite rational number with a
|
| 7058 |
numerator and denominator representable by compile-time constants of
|
| 7059 |
type `intmax_t`.
|
| 7060 |
|
| 7061 |
+
Throughout this subclause, the names of template parameters are used to
|
| 7062 |
+
express type requirements. If a template parameter is named `R1` or
|
| 7063 |
+
`R2`, and the template argument is not a specialization of the `ratio`
|
| 7064 |
+
template, the program is ill-formed.
|
| 7065 |
|
| 7066 |
### Header `<ratio>` synopsis <a id="ratio.syn">[[ratio.syn]]</a>
|
| 7067 |
|
| 7068 |
``` cpp
|
| 7069 |
namespace std {
|
|
|
|
| 7083 |
template <class R1, class R2> struct ratio_less_equal;
|
| 7084 |
template <class R1, class R2> struct ratio_greater;
|
| 7085 |
template <class R1, class R2> struct ratio_greater_equal;
|
| 7086 |
|
| 7087 |
// [ratio.si], convenience SI typedefs
|
| 7088 |
+
typedef ratio<1, 1'000'000'000'000'000'000'000'000> yocto; // see below
|
| 7089 |
+
typedef ratio<1, 1'000'000'000'000'000'000'000> zepto; // see below
|
| 7090 |
+
typedef ratio<1, 1'000'000'000'000'000'000> atto;
|
| 7091 |
+
typedef ratio<1, 1'000'000'000'000'000> femto;
|
| 7092 |
+
typedef ratio<1, 1'000'000'000'000> pico;
|
| 7093 |
+
typedef ratio<1, 1'000'000'000> nano;
|
| 7094 |
+
typedef ratio<1, 1'000'000> micro;
|
| 7095 |
+
typedef ratio<1, 1'000> milli;
|
| 7096 |
typedef ratio<1, 100> centi;
|
| 7097 |
typedef ratio<1, 10> deci;
|
| 7098 |
typedef ratio< 10, 1> deca;
|
| 7099 |
typedef ratio< 100, 1> hecto;
|
| 7100 |
+
typedef ratio< 1'000, 1> kilo;
|
| 7101 |
+
typedef ratio< 1'000'000, 1> mega;
|
| 7102 |
+
typedef ratio< 1'000'000'000, 1> giga;
|
| 7103 |
+
typedef ratio< 1'000'000'000'000, 1> tera;
|
| 7104 |
+
typedef ratio< 1'000'000'000'000'000, 1> peta;
|
| 7105 |
+
typedef ratio< 1'000'000'000'000'000'000, 1> exa;
|
| 7106 |
+
typedef ratio< 1'000'000'000'000'000'000'000, 1> zetta; // see below
|
| 7107 |
+
typedef ratio<1'000'000'000'000'000'000'000'000, 1> yotta; // see below
|
| 7108 |
}
|
| 7109 |
```
|
| 7110 |
|
| 7111 |
### Class template `ratio` <a id="ratio.ratio">[[ratio.ratio]]</a>
|
| 7112 |
|
| 7113 |
``` cpp
|
| 7114 |
namespace std {
|
| 7115 |
template <intmax_t N, intmax_t D = 1>
|
| 7116 |
class ratio {
|
| 7117 |
public:
|
|
|
|
| 7118 |
static constexpr intmax_t num;
|
| 7119 |
static constexpr intmax_t den;
|
| 7120 |
+
typedef ratio<num, den> type;
|
| 7121 |
};
|
| 7122 |
}
|
| 7123 |
```
|
| 7124 |
|
| 7125 |
If the template argument `D` is zero or the absolute values of either of
|
|
|
|
| 7266 |
template <class Rep> struct treat_as_floating_point;
|
| 7267 |
template <class Rep> struct duration_values;
|
| 7268 |
|
| 7269 |
// [time.duration.nonmember], duration arithmetic
|
| 7270 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7271 |
+
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 7272 |
constexpr operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7273 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7274 |
+
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 7275 |
constexpr operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7276 |
template <class Rep1, class Period, class Rep2>
|
| 7277 |
+
duration<common_type_t<Rep1, Rep2>, Period>
|
| 7278 |
constexpr operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7279 |
template <class Rep1, class Rep2, class Period>
|
| 7280 |
+
duration<common_type_t<Rep1, Rep2>, Period>
|
| 7281 |
constexpr operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 7282 |
template <class Rep1, class Period, class Rep2>
|
| 7283 |
+
duration<common_type_t<Rep1, Rep2>, Period>
|
| 7284 |
constexpr operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7285 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7286 |
+
common_type_t<Rep1, Rep2>
|
| 7287 |
constexpr operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7288 |
template <class Rep1, class Period, class Rep2>
|
| 7289 |
+
duration<common_type_t<Rep1, Rep2>, Period>
|
| 7290 |
constexpr operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7291 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7292 |
+
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 7293 |
constexpr operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7294 |
|
| 7295 |
// [time.duration.comparisons], duration comparisons
|
| 7296 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7297 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs,
|
|
|
|
| 7324 |
typedef duration<signed integer type of at least 29 bits, ratio< 60>> minutes;
|
| 7325 |
typedef duration<signed integer type of at least 23 bits, ratio<3600>> hours;
|
| 7326 |
|
| 7327 |
// [time.point.nonmember], time_point arithmetic
|
| 7328 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 7329 |
+
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 7330 |
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7331 |
template <class Rep1, class Period1, class Clock, class Duration2>
|
| 7332 |
+
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
| 7333 |
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7334 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 7335 |
+
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 7336 |
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7337 |
template <class Clock, class Duration1, class Duration2>
|
| 7338 |
+
constexpr common_type_t<Duration1, Duration2>
|
| 7339 |
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 7340 |
|
| 7341 |
// [time.point.comparisons] time_point comparisons
|
| 7342 |
template <class Clock, class Duration1, class Duration2>
|
| 7343 |
+
constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
|
| 7344 |
const time_point<Clock, Duration2>& rhs);
|
| 7345 |
template <class Clock, class Duration1, class Duration2>
|
| 7346 |
+
constexpr bool operator!=(const time_point<Clock, Duration1>& lhs,
|
| 7347 |
const time_point<Clock, Duration2>& rhs);
|
| 7348 |
template <class Clock, class Duration1, class Duration2>
|
| 7349 |
+
constexpr bool operator< (const time_point<Clock, Duration1>& lhs,
|
| 7350 |
const time_point<Clock, Duration2>& rhs);
|
| 7351 |
template <class Clock, class Duration1, class Duration2>
|
| 7352 |
+
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
|
| 7353 |
const time_point<Clock, Duration2>& rhs);
|
| 7354 |
template <class Clock, class Duration1, class Duration2>
|
| 7355 |
+
constexpr bool operator> (const time_point<Clock, Duration1>& lhs,
|
| 7356 |
const time_point<Clock, Duration2>& rhs);
|
| 7357 |
template <class Clock, class Duration1, class Duration2>
|
| 7358 |
+
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
|
| 7359 |
const time_point<Clock, Duration2>& rhs);
|
| 7360 |
|
| 7361 |
// [time.point.cast], time_point_cast
|
|
|
|
| 7362 |
template <class ToDuration, class Clock, class Duration>
|
| 7363 |
+
constexpr time_point<Clock, ToDuration>
|
| 7364 |
+
time_point_cast(const time_point<Clock, Duration>& t);
|
| 7365 |
|
| 7366 |
// [time.clock], clocks
|
| 7367 |
class system_clock;
|
| 7368 |
class steady_clock;
|
| 7369 |
class high_resolution_clock;
|
| 7370 |
|
| 7371 |
} // namespace chrono
|
| 7372 |
+
|
| 7373 |
+
inline namespace literals {
|
| 7374 |
+
inline namespace chrono_literals {
|
| 7375 |
+
|
| 7376 |
+
// ~[time.duration.literals], suffixes for duration literals
|
| 7377 |
+
constexpr chrono::hours operator "" h(unsigned long long);
|
| 7378 |
+
constexpr chrono::duration<unspecified, ratio<3600,1>> operator "" h(long double);
|
| 7379 |
+
constexpr chrono::minutes operator "" min(unsigned long long);
|
| 7380 |
+
constexpr chrono::duration<unspecified, ratio<60,1>> operator "" min(long double);
|
| 7381 |
+
constexpr chrono::seconds operator "" s(unsigned long long);
|
| 7382 |
+
constexpr chrono::duration<unspecified> operator "" s(long double);
|
| 7383 |
+
constexpr chrono::milliseconds operator "" ms(unsigned long long);
|
| 7384 |
+
constexpr chrono::duration<unspecified, milli> operator "" ms(long double);
|
| 7385 |
+
constexpr chrono::microseconds operator "" us(unsigned long long);
|
| 7386 |
+
constexpr chrono::duration<unspecified, micro> operator "" us(long double);
|
| 7387 |
+
constexpr chrono::nanoseconds operator "" ns(unsigned long long);
|
| 7388 |
+
constexpr chrono::duration<unspecified, nano> operator "" ns(long double);
|
| 7389 |
+
|
| 7390 |
+
} // namespace chrono_literals
|
| 7391 |
+
} // namespace literals
|
| 7392 |
+
|
| 7393 |
+
namespace chrono {
|
| 7394 |
+
|
| 7395 |
+
using namespace literals::chrono_literals;
|
| 7396 |
+
|
| 7397 |
+
} // namespace chrono
|
| 7398 |
+
|
| 7399 |
} // namespace std
|
| 7400 |
```
|
| 7401 |
|
| 7402 |
### Clock requirements <a id="time.clock.req">[[time.clock.req]]</a>
|
| 7403 |
|
| 7404 |
A clock is a bundle consisting of a `duration`, a `time_point`, and a
|
| 7405 |
+
function `now()` to get the current `time_point`. The origin of the
|
| 7406 |
clock’s `time_point` is referred to as the clock’s *epoch*. A clock
|
| 7407 |
shall meet the requirements in Table [[tab:time.clock]].
|
| 7408 |
|
| 7409 |
In Table [[tab:time.clock]] `C1` and `C2` denote clock types. `t1` and
|
| 7410 |
`t2` are values returned by `C1::now()` where the call returning `t1`
|
|
|
|
| 7429 |
this means, in particular, that operations on these types will not
|
| 7430 |
throw exceptions.
|
| 7431 |
- lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
|
| 7432 |
are swappable ([[swappable.requirements]]),
|
| 7433 |
- the function `TC::now()` does not throw exceptions, and
|
| 7434 |
+
- the type `TC::time_point::clock` meets the `TrivialClock`
|
| 7435 |
+
requirements, recursively.
|
| 7436 |
|
| 7437 |
### Time-related traits <a id="time.traits">[[time.traits]]</a>
|
| 7438 |
|
| 7439 |
#### `treat_as_floating_point` <a id="time.traits.is_fp">[[time.traits.is_fp]]</a>
|
| 7440 |
|
|
|
|
| 7502 |
#### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
|
| 7503 |
|
| 7504 |
``` cpp
|
| 7505 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7506 |
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
|
| 7507 |
+
typedef chrono::duration<common_type_t<Rep1, Rep2>, see below> type;
|
| 7508 |
};
|
| 7509 |
```
|
| 7510 |
|
| 7511 |
The `period` of the `duration` indicated by this specialization of
|
| 7512 |
`common_type` shall be the greatest common divisor of `Period1` and
|
|
|
|
| 7522 |
durations may have round-off errors.
|
| 7523 |
|
| 7524 |
``` cpp
|
| 7525 |
template <class Clock, class Duration1, class Duration2>
|
| 7526 |
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
|
| 7527 |
+
typedef chrono::time_point<Clock, common_type_t<Duration1, Duration2>> type;
|
| 7528 |
};
|
| 7529 |
```
|
| 7530 |
|
| 7531 |
The common type of two `time_point` types is a `time_point` with the
|
| 7532 |
same clock as the two types and the common type of their two
|
|
|
|
| 7597 |
*Remarks:* If `Period::num` is not positive, the program is ill-formed.
|
| 7598 |
|
| 7599 |
*Requires:* Members of `duration` shall not throw exceptions other than
|
| 7600 |
those thrown by the indicated operations on their representations.
|
| 7601 |
|
| 7602 |
+
*Remarks:* The defaulted copy constructor of duration shall be a
|
| 7603 |
+
`constexpr` function if and only if the required initialization of the
|
| 7604 |
+
member `rep_` for copy and move, respectively, would satisfy the
|
| 7605 |
+
requirements for a `constexpr` function.
|
| 7606 |
+
|
| 7607 |
``` cpp
|
| 7608 |
duration<long, ratio<60>> d0; // holds a count of minutes using a long
|
| 7609 |
duration<long long, milli> d1; // holds a count of milliseconds using a long long
|
| 7610 |
duration<double, ratio<1, 30>> d2; // holds a count with a tick period of $\frac{1}{30}$ of a second
|
| 7611 |
// (30 Hz) using a double
|
|
|
|
| 7637 |
template <class Rep2, class Period2>
|
| 7638 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 7639 |
```
|
| 7640 |
|
| 7641 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 7642 |
+
unless no overflow is induced in the conversion and
|
| 7643 |
+
`treat_as_floating_point<rep>::value` is `true` or both
|
| 7644 |
`ratio_divide<Period2, period>::den` is `1` and
|
| 7645 |
`treat_as_floating_point<Rep2>::value` is `false`. This requirement
|
| 7646 |
prevents implicit truncation error when converting between
|
| 7647 |
integral-based `duration` types. Such a construction could easily lead
|
| 7648 |
to confusion about the value of the `duration`.
|
|
|
|
| 7776 |
*Returns:* `duration(duration_values<rep>::max())`.
|
| 7777 |
|
| 7778 |
#### `duration` non-member arithmetic <a id="time.duration.nonmember">[[time.duration.nonmember]]</a>
|
| 7779 |
|
| 7780 |
In the function descriptions that follow, `CD` represents the return
|
| 7781 |
+
type of the function. `CR(A,B)` represents `common_type_t<A, B>`.
|
| 7782 |
|
| 7783 |
``` cpp
|
| 7784 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7785 |
+
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 7786 |
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7787 |
```
|
| 7788 |
|
| 7789 |
*Returns:* CD(CD(lhs).count() + CD(rhs).count()).
|
| 7790 |
|
| 7791 |
``` cpp
|
| 7792 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7793 |
+
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 7794 |
operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7795 |
```
|
| 7796 |
|
| 7797 |
*Returns:* CD(CD(lhs).count() - CD(rhs).count()).
|
| 7798 |
|
| 7799 |
``` cpp
|
| 7800 |
template <class Rep1, class Period, class Rep2>
|
| 7801 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 7802 |
operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7803 |
```
|
| 7804 |
|
| 7805 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7806 |
unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)`.
|
| 7807 |
|
| 7808 |
*Returns:* CD(CD(d).count() \* s).
|
| 7809 |
|
| 7810 |
``` cpp
|
| 7811 |
template <class Rep1, class Rep2, class Period>
|
| 7812 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 7813 |
operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 7814 |
```
|
| 7815 |
|
| 7816 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7817 |
unless `Rep1` is implicitly convertible to `CR(Rep1, Rep2)`.
|
| 7818 |
|
| 7819 |
*Returns:* `d * s`.
|
| 7820 |
|
| 7821 |
``` cpp
|
| 7822 |
template <class Rep1, class Period, class Rep2>
|
| 7823 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 7824 |
operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7825 |
```
|
| 7826 |
|
| 7827 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7828 |
unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
|
|
|
|
| 7830 |
|
| 7831 |
*Returns:* CD(CD(d).count() / s).
|
| 7832 |
|
| 7833 |
``` cpp
|
| 7834 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7835 |
+
constexpr common_type_t<Rep1, Rep2>
|
| 7836 |
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7837 |
```
|
| 7838 |
|
| 7839 |
*Returns:* `CD(lhs).count() / CD(rhs).count()`.
|
| 7840 |
|
| 7841 |
``` cpp
|
| 7842 |
template <class Rep1, class Period, class Rep2>
|
| 7843 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 7844 |
operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 7845 |
```
|
| 7846 |
|
| 7847 |
*Remarks:* This operator shall not participate in overload resolution
|
| 7848 |
unless `Rep2` is implicitly convertible to `CR(Rep1, Rep2)` and `Rep2`
|
|
|
|
| 7850 |
|
| 7851 |
*Returns:* CD(CD(d).count() % s).
|
| 7852 |
|
| 7853 |
``` cpp
|
| 7854 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7855 |
+
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 7856 |
operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 7857 |
```
|
| 7858 |
|
| 7859 |
*Returns:* CD(CD(lhs).count() % CD(rhs).count()).
|
| 7860 |
|
| 7861 |
#### `duration` comparisons <a id="time.duration.comparisons">[[time.duration.comparisons]]</a>
|
| 7862 |
|
| 7863 |
In the function descriptions that follow, `CT` represents
|
| 7864 |
+
`common_type_t<A, B>`, where `A` and `B` are the types of the two
|
| 7865 |
arguments to the function.
|
| 7866 |
|
| 7867 |
``` cpp
|
| 7868 |
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 7869 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 7945 |
divisions when it is known at compile time that one or more arguments
|
| 7946 |
is 1. Intermediate computations are carried out in the widest
|
| 7947 |
representation and only converted to the destination representation at
|
| 7948 |
the final step.
|
| 7949 |
|
| 7950 |
+
#### Suffixes for duration literals <a id="time.duration.literals">[[time.duration.literals]]</a>
|
| 7951 |
+
|
| 7952 |
+
This section describes literal suffixes for constructing duration
|
| 7953 |
+
literals. The suffixes `h`, `min`, `s`, `ms`, `us`, `ns` denote duration
|
| 7954 |
+
values of the corresponding types `hours`, `minutes`, `seconds`,
|
| 7955 |
+
`milliseconds`, `microseconds`, and `nanoseconds` respectively if they
|
| 7956 |
+
are applied to integral literals.
|
| 7957 |
+
|
| 7958 |
+
If any of these suffixes are applied to a floating point literal the
|
| 7959 |
+
result is a `chrono::duration` literal with an unspecified floating
|
| 7960 |
+
point representation.
|
| 7961 |
+
|
| 7962 |
+
If any of these suffixes are applied to an integer literal and the
|
| 7963 |
+
resulting `chrono::duration` value cannot be represented in the result
|
| 7964 |
+
type because of overflow, the program is ill-formed.
|
| 7965 |
+
|
| 7966 |
+
The following code shows some duration literals.
|
| 7967 |
+
|
| 7968 |
+
``` cpp
|
| 7969 |
+
using namespace std::chrono_literals;
|
| 7970 |
+
auto constexpr aday=24h;
|
| 7971 |
+
auto constexpr lesson=45min;
|
| 7972 |
+
auto constexpr halfanhour=0.5h;
|
| 7973 |
+
```
|
| 7974 |
+
|
| 7975 |
+
``` cpp
|
| 7976 |
+
constexpr chrono::hours operator "" h(unsigned long long hours);
|
| 7977 |
+
constexpr chrono::duration<unspecified, ratio<3600,1>> operator "" h(long double hours);
|
| 7978 |
+
```
|
| 7979 |
+
|
| 7980 |
+
*Returns:* A `duration` literal representing `hours` hours.
|
| 7981 |
+
|
| 7982 |
+
``` cpp
|
| 7983 |
+
constexpr chrono::minutes operator "" min(unsigned long long minutes);
|
| 7984 |
+
constexpr chrono::duration<unspecified, ratio<60,1>> operator "" min(long double minutes);
|
| 7985 |
+
```
|
| 7986 |
+
|
| 7987 |
+
*Returns:* A `duration` literal representing `minutes` minutes.
|
| 7988 |
+
|
| 7989 |
+
``` cpp
|
| 7990 |
+
constexpr chrono::seconds operator "" s(unsigned long long sec);
|
| 7991 |
+
constexpr chrono::duration<unspecified> operator "" s(long double sec);
|
| 7992 |
+
```
|
| 7993 |
+
|
| 7994 |
+
*Returns:* A `duration` literal representing `sec` seconds.
|
| 7995 |
+
|
| 7996 |
+
The same suffix `s` is used for `basic_string` but there is no conflict,
|
| 7997 |
+
since duration suffixes apply to numbers and string literal suffixes
|
| 7998 |
+
apply to character array literals.
|
| 7999 |
+
|
| 8000 |
+
``` cpp
|
| 8001 |
+
constexpr chrono::milliseconds operator "" ms(unsigned long long msec);
|
| 8002 |
+
constexpr chrono::duration<unspecified, milli> operator "" ms(long double msec);
|
| 8003 |
+
```
|
| 8004 |
+
|
| 8005 |
+
*Returns:* A `duration` literal representing `msec` milliseconds.
|
| 8006 |
+
|
| 8007 |
+
``` cpp
|
| 8008 |
+
constexpr chrono::microseconds operator "" us(unsigned long long usec);
|
| 8009 |
+
constexpr chrono::duration<unspecified, micro> operator "" us(long double usec);
|
| 8010 |
+
```
|
| 8011 |
+
|
| 8012 |
+
*Returns:* A `duration` literal representing `usec` microseconds.
|
| 8013 |
+
|
| 8014 |
+
``` cpp
|
| 8015 |
+
constexpr chrono::nanoseconds operator "" ns(unsigned long long nsec);
|
| 8016 |
+
constexpr chrono::duration<unspecified, nano> operator "" ns(long double nsec);
|
| 8017 |
+
```
|
| 8018 |
+
|
| 8019 |
+
*Returns:* A `duration` literal representing `nsec` nanoseconds.
|
| 8020 |
+
|
| 8021 |
### Class template `time_point` <a id="time.point">[[time.point]]</a>
|
| 8022 |
|
| 8023 |
``` cpp
|
| 8024 |
template <class Clock, class Duration = typename Clock::duration>
|
| 8025 |
class time_point {
|
|
|
|
| 8031 |
private:
|
| 8032 |
duration d_; // exposition only
|
| 8033 |
|
| 8034 |
public:
|
| 8035 |
// [time.point.cons], construct:
|
| 8036 |
+
constexpr time_point(); // has value epoch
|
| 8037 |
+
constexpr explicit time_point(const duration& d); // same as time_point() + d
|
| 8038 |
template <class Duration2>
|
| 8039 |
+
constexpr time_point(const time_point<clock, Duration2>& t);
|
| 8040 |
|
| 8041 |
// [time.point.observer], observer:
|
| 8042 |
+
constexpr duration time_since_epoch() const;
|
| 8043 |
|
| 8044 |
// [time.point.arithmetic], arithmetic:
|
| 8045 |
time_point& operator+=(const duration& d);
|
| 8046 |
time_point& operator-=(const duration& d);
|
| 8047 |
|
|
|
|
| 8057 |
ill-formed.
|
| 8058 |
|
| 8059 |
#### `time_point` constructors <a id="time.point.cons">[[time.point.cons]]</a>
|
| 8060 |
|
| 8061 |
``` cpp
|
| 8062 |
+
constexpr time_point();
|
| 8063 |
```
|
| 8064 |
|
| 8065 |
*Effects:* Constructs an object of type `time_point`, initializing `d_`
|
| 8066 |
with `duration::zero()`. Such a `time_point` object represents the
|
| 8067 |
epoch.
|
| 8068 |
|
| 8069 |
``` cpp
|
| 8070 |
+
constexpr explicit time_point(const duration& d);
|
| 8071 |
```
|
| 8072 |
|
| 8073 |
*Effects:* Constructs an object of type `time_point`, initializing `d_`
|
| 8074 |
with `d`. Such a `time_point` object represents the epoch `+ d`.
|
| 8075 |
|
| 8076 |
``` cpp
|
| 8077 |
template <class Duration2>
|
| 8078 |
+
constexpr time_point(const time_point<clock, Duration2>& t);
|
| 8079 |
```
|
| 8080 |
|
| 8081 |
*Remarks:* This constructor shall not participate in overload resolution
|
| 8082 |
unless `Duration2` is implicitly convertible to `duration`.
|
| 8083 |
|
|
|
|
| 8085 |
with `t.time_since_epoch()`.
|
| 8086 |
|
| 8087 |
#### `time_point` observer <a id="time.point.observer">[[time.point.observer]]</a>
|
| 8088 |
|
| 8089 |
``` cpp
|
| 8090 |
+
constexpr duration time_since_epoch() const;
|
| 8091 |
```
|
| 8092 |
|
| 8093 |
*Returns:* `d_`.
|
| 8094 |
|
| 8095 |
#### `time_point` arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
|
|
|
|
| 8126 |
|
| 8127 |
#### `time_point` non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
|
| 8128 |
|
| 8129 |
``` cpp
|
| 8130 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 8131 |
+
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 8132 |
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 8133 |
```
|
| 8134 |
|
| 8135 |
+
*Returns:* `CT(lhs.time_since_epoch() + rhs)`, where `CT` is the type of
|
| 8136 |
+
the return value.
|
| 8137 |
|
| 8138 |
``` cpp
|
| 8139 |
template <class Rep1, class Period1, class Clock, class Duration2>
|
| 8140 |
+
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
| 8141 |
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8142 |
```
|
| 8143 |
|
| 8144 |
*Returns:* `rhs + lhs`.
|
| 8145 |
|
| 8146 |
``` cpp
|
| 8147 |
template <class Clock, class Duration1, class Rep2, class Period2>
|
| 8148 |
+
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 8149 |
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 8150 |
```
|
| 8151 |
|
| 8152 |
*Returns:* `lhs + (-rhs)`.
|
| 8153 |
|
| 8154 |
``` cpp
|
| 8155 |
template <class Clock, class Duration1, class Duration2>
|
| 8156 |
+
constexpr common_type_t<Duration1, Duration2>
|
| 8157 |
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8158 |
```
|
| 8159 |
|
| 8160 |
*Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
|
| 8161 |
|
| 8162 |
#### `time_point` comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
|
| 8163 |
|
| 8164 |
``` cpp
|
| 8165 |
template <class Clock, class Duration1, class Duration2>
|
| 8166 |
+
constexpr bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8167 |
```
|
| 8168 |
|
| 8169 |
*Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
|
| 8170 |
|
| 8171 |
``` cpp
|
| 8172 |
template <class Clock, class Duration1, class Duration2>
|
| 8173 |
+
constexpr bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8174 |
```
|
| 8175 |
|
| 8176 |
*Returns:* `!(lhs == rhs)`.
|
| 8177 |
|
| 8178 |
``` cpp
|
| 8179 |
template <class Clock, class Duration1, class Duration2>
|
| 8180 |
+
constexpr bool operator<(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8181 |
```
|
| 8182 |
|
| 8183 |
*Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
|
| 8184 |
|
| 8185 |
``` cpp
|
| 8186 |
template <class Clock, class Duration1, class Duration2>
|
| 8187 |
+
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8188 |
```
|
| 8189 |
|
| 8190 |
*Returns:* `!(rhs < lhs)`.
|
| 8191 |
|
| 8192 |
``` cpp
|
| 8193 |
template <class Clock, class Duration1, class Duration2>
|
| 8194 |
+
constexpr bool operator>(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8195 |
```
|
| 8196 |
|
| 8197 |
*Returns:* `rhs < lhs`.
|
| 8198 |
|
| 8199 |
``` cpp
|
| 8200 |
template <class Clock, class Duration1, class Duration2>
|
| 8201 |
+
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 8202 |
```
|
| 8203 |
|
| 8204 |
*Returns:* `!(lhs < rhs)`.
|
| 8205 |
|
| 8206 |
#### `time_point_cast` <a id="time.point.cast">[[time.point.cast]]</a>
|
| 8207 |
|
| 8208 |
``` cpp
|
| 8209 |
template <class ToDuration, class Clock, class Duration>
|
| 8210 |
+
constexpr time_point<Clock, ToDuration>
|
| 8211 |
+
time_point_cast(const time_point<Clock, Duration>& t);
|
| 8212 |
```
|
| 8213 |
|
| 8214 |
*Remarks:* This function shall not participate in overload resolution
|
| 8215 |
unless `ToDuration` is an instantiation of `duration`.
|
| 8216 |
|
|
|
|
| 8232 |
public:
|
| 8233 |
typedef see below rep;
|
| 8234 |
typedef ratio<unspecified, unspecified> period;
|
| 8235 |
typedef chrono::duration<rep, period> duration;
|
| 8236 |
typedef chrono::time_point<system_clock> time_point;
|
| 8237 |
+
static constexpr bool is_steady = unspecified;
|
| 8238 |
|
| 8239 |
static time_point now() noexcept;
|
| 8240 |
|
| 8241 |
// Map to C API
|
| 8242 |
static time_t to_time_t (const time_point& t) noexcept;
|
|
|
|
| 8282 |
public:
|
| 8283 |
typedef unspecified rep;
|
| 8284 |
typedef ratio<unspecified, unspecified> period;
|
| 8285 |
typedef chrono::duration<rep, period> duration;
|
| 8286 |
typedef chrono::time_point<unspecified, duration> time_point;
|
| 8287 |
+
static constexpr bool is_steady = true;
|
| 8288 |
|
| 8289 |
static time_point now() noexcept;
|
| 8290 |
};
|
| 8291 |
```
|
| 8292 |
|
|
|
|
| 8301 |
public:
|
| 8302 |
typedef unspecified rep;
|
| 8303 |
typedef ratio<unspecified, unspecified> period;
|
| 8304 |
typedef chrono::duration<rep, period> duration;
|
| 8305 |
typedef chrono::time_point<unspecified, duration> time_point;
|
| 8306 |
+
static constexpr bool is_steady = unspecified;
|
| 8307 |
|
| 8308 |
static time_point now() noexcept;
|
| 8309 |
};
|
| 8310 |
```
|
| 8311 |
|
|
|
|
| 8412 |
pointer allocate(size_type n, const_void_pointer hint);
|
| 8413 |
void deallocate(pointer p, size_type n);
|
| 8414 |
size_type max_size() const;
|
| 8415 |
|
| 8416 |
template <class T, class... Args>
|
| 8417 |
+
void construct(T* p, Args&&... args);
|
| 8418 |
template <class T1, class T2, class... Args1, class... Args2>
|
| 8419 |
void construct(pair<T1, T2>* p, piecewise_construct_t,
|
| 8420 |
tuple<Args1...> x, tuple<Args2...> y);
|
| 8421 |
template <class T1, class T2>
|
| 8422 |
void construct(pair<T1, T2>* p);
|
|
|
|
| 8483 |
|
| 8484 |
``` cpp
|
| 8485 |
scoped_allocator_adaptor();
|
| 8486 |
```
|
| 8487 |
|
| 8488 |
+
*Effects:* value-initializes the `OuterAlloc` base class and the `inner`
|
| 8489 |
allocator object.
|
| 8490 |
|
| 8491 |
``` cpp
|
| 8492 |
template <class OuterA2>
|
| 8493 |
scoped_allocator_adaptor(OuterA2&& outerAlloc,
|
|
|
|
| 8640 |
`x`.
|
| 8641 |
- Otherwise, if `uses_allocator<T1, inner_allocator_type>::value` is
|
| 8642 |
`true` and
|
| 8643 |
`is_constructible<T1, allocator_arg_t, inner_allocator_type, Args1...>::value`
|
| 8644 |
is `true`, then `xprime` is
|
| 8645 |
+
`tuple_cat(tuple<allocator_arg_t, inner_allocator_type&>( allocator_arg, inner_allocator()), std::move(x))`.
|
| 8646 |
- Otherwise, if `uses_allocator<T1, inner_allocator_type>::value` is
|
| 8647 |
`true` and
|
| 8648 |
`is_constructible<T1, Args1..., inner_allocator_type>::value` is
|
| 8649 |
`true`, then `xprime` is
|
| 8650 |
+
`tuple_cat(std::move(x), tuple<inner_allocator_type&>(inner_allocator()))`.
|
| 8651 |
- Otherwise, the program is ill-formed.
|
| 8652 |
|
| 8653 |
and constructs a `tuple` object `yprime` from `y` by the following
|
| 8654 |
rules:
|
| 8655 |
|
|
|
|
| 8658 |
`y`.
|
| 8659 |
- Otherwise, if `uses_allocator<T2, inner_allocator_type>::value` is
|
| 8660 |
`true` and
|
| 8661 |
`is_constructible<T2, allocator_arg_t, inner_allocator_type, Args2...>::value`
|
| 8662 |
is `true`, then `yprime` is
|
| 8663 |
+
`tuple_cat(tuple<allocator_arg_t, inner_allocator_type&>( allocator_arg, inner_allocator()), std::move(y))`.
|
| 8664 |
- Otherwise, if `uses_allocator<T2, inner_allocator_type>::value` is
|
| 8665 |
`true` and
|
| 8666 |
`is_constructible<T2, Args2..., inner_allocator_type>::value` is
|
| 8667 |
`true`, then `yprime` is
|
| 8668 |
+
`tuple_cat(std::move(y), tuple<inner_allocator_type&>(inner_allocator()))`.
|
| 8669 |
- Otherwise, the program is ill-formed.
|
| 8670 |
|
| 8671 |
then calls
|
| 8672 |
*`OUTERMOST_ALLOC_TRAITS`*`(*this)::construct(`*`OUTERMOST`*`(*this), p,`
|
| 8673 |
+
`piecewise_construct, std::move(xprime), std::move(yprime))`.
|
| 8674 |
|
| 8675 |
``` cpp
|
| 8676 |
template <class T1, class T2>
|
| 8677 |
void construct(pair<T1, T2>* p);
|
| 8678 |
```
|
| 8679 |
|
| 8680 |
+
*Effects:* Equivalent to
|
| 8681 |
`this->construct(p, piecewise_construct, tuple<>(), tuple<>())`.
|
| 8682 |
|
| 8683 |
``` cpp
|
| 8684 |
template <class T1, class T2, class U, class V>
|
| 8685 |
void construct(pair<T1, T2>* p, U&& x, V&& y);
|
| 8686 |
```
|
| 8687 |
|
| 8688 |
+
*Effects:* Equivalent to
|
| 8689 |
`this->construct(p, piecewise_construct, forward_as_tuple(std::forward<U>(x)), forward_as_tuple(std::forward<V>(y)))`.
|
| 8690 |
|
| 8691 |
``` cpp
|
| 8692 |
template <class T1, class T2, class U, class V>
|
| 8693 |
void construct(pair<T1, T2>* p, const pair<U, V>& x);
|
| 8694 |
```
|
| 8695 |
|
| 8696 |
+
*Effects:* Equivalent to
|
| 8697 |
`this->construct(p, piecewise_construct, forward_as_tuple(x.first), forward_as_tuple(x.second))`.
|
| 8698 |
|
| 8699 |
``` cpp
|
| 8700 |
template <class T1, class T2, class U, class V>
|
| 8701 |
void construct(pair<T1, T2>* p, pair<U, V>&& x);
|
| 8702 |
```
|
| 8703 |
|
| 8704 |
+
*Effects:* Equivalent to
|
| 8705 |
`this->construct(p, piecewise_construct, forward_as_tuple(std::forward<U>(x.first)), forward_as_tuple(std::forward<V>(x.second)))`.
|
| 8706 |
|
| 8707 |
``` cpp
|
| 8708 |
template <class T>
|
| 8709 |
void destroy(T* p);
|
|
|
|
| 8765 |
bool operator!=(const type_index& rhs) const noexcept;
|
| 8766 |
bool operator< (const type_index& rhs) const noexcept;
|
| 8767 |
bool operator<= (const type_index& rhs) const noexcept;
|
| 8768 |
bool operator> (const type_index& rhs) const noexcept;
|
| 8769 |
bool operator>= (const type_index& rhs) const noexcept;
|
| 8770 |
+
size_t hash_code() const noexcept;
|
| 8771 |
+
const char* name() const noexcept;
|
| 8772 |
private:
|
| 8773 |
const type_info* target; // exposition only
|
| 8774 |
// Note that the use of a pointer here, rather than a reference,
|
| 8775 |
// means that the default copy/move constructor and assignment
|
| 8776 |
// operators will be provided and work as expected.
|
|
|
|
| 8826 |
```
|
| 8827 |
|
| 8828 |
*Returns:* `!target->before(*rhs.target)`
|
| 8829 |
|
| 8830 |
``` cpp
|
| 8831 |
+
size_t hash_code() const noexcept;
|
| 8832 |
```
|
| 8833 |
|
| 8834 |
*Returns:* `target->hash_code()`
|
| 8835 |
|
| 8836 |
``` cpp
|
| 8837 |
+
const char* name() const noexcept;
|
| 8838 |
```
|
| 8839 |
|
| 8840 |
*Returns:* `target->name()`
|
| 8841 |
|
| 8842 |
### Hash support <a id="type.index.hash">[[type.index.hash]]</a>
|
| 8843 |
|
| 8844 |
``` cpp
|
| 8845 |
template <> struct hash<type_index>;
|
| 8846 |
```
|
| 8847 |
|
| 8848 |
+
The template specialization shall meet the requirements of class
|
| 8849 |
+
template `hash` ([[unord.hash]]). For an object `index` of type
|
| 8850 |
`type_index`, `hash<type_index>()(index)` shall evaluate to the same
|
| 8851 |
result as `index.hash_code()`.
|
| 8852 |
|
| 8853 |
<!-- Link reference definitions -->
|
| 8854 |
[alg.sorting]: algorithms.md#alg.sorting
|
|
|
|
| 8879 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 8880 |
[basic.life]: basic.md#basic.life
|
| 8881 |
[basic.stc.dynamic.safety]: basic.md#basic.stc.dynamic.safety
|
| 8882 |
[basic.type.qualifier]: basic.md#basic.type.qualifier
|
| 8883 |
[basic.types]: basic.md#basic.types
|
|
|
|
| 8884 |
[bitset.cons]: #bitset.cons
|
| 8885 |
[bitset.hash]: #bitset.hash
|
| 8886 |
[bitset.members]: #bitset.members
|
| 8887 |
[bitset.operators]: #bitset.operators
|
| 8888 |
[bitwise.operations]: #bitwise.operations
|
| 8889 |
[c.malloc]: #c.malloc
|
| 8890 |
[c.strings]: strings.md#c.strings
|
| 8891 |
+
[class]: class.md#class
|
| 8892 |
[class.abstract]: class.md#class.abstract
|
| 8893 |
[class.derived]: class.md#class.derived
|
| 8894 |
[class.dtor]: special.md#class.dtor
|
| 8895 |
[class.virtual]: class.md#class.virtual
|
| 8896 |
[comparisons]: #comparisons
|
|
|
|
| 8926 |
[forward]: #forward
|
| 8927 |
[forward.iterators]: iterators.md#forward.iterators
|
| 8928 |
[func.bind]: #func.bind
|
| 8929 |
[func.bind.bind]: #func.bind.bind
|
| 8930 |
[func.bind.isbind]: #func.bind.isbind
|
| 8931 |
+
[func.bind.isplace]: #func.bind.isplace
|
| 8932 |
[func.bind.place]: #func.bind.place
|
| 8933 |
[func.def]: #func.def
|
| 8934 |
[func.memfn]: #func.memfn
|
| 8935 |
[func.require]: #func.require
|
| 8936 |
[func.wrap]: #func.wrap
|
|
|
|
| 8946 |
[func.wrap.func.targ]: #func.wrap.func.targ
|
| 8947 |
[function.objects]: #function.objects
|
| 8948 |
[hash.requirements]: library.md#hash.requirements
|
| 8949 |
[input.iterators]: iterators.md#input.iterators
|
| 8950 |
[intro.multithread]: intro.md#intro.multithread
|
| 8951 |
+
[intseq]: #intseq
|
| 8952 |
+
[intseq.general]: #intseq.general
|
| 8953 |
+
[intseq.intseq]: #intseq.intseq
|
| 8954 |
+
[intseq.make]: #intseq.make
|
| 8955 |
[invalid.argument]: diagnostics.md#invalid.argument
|
| 8956 |
[iostate.flags]: input.md#iostate.flags
|
| 8957 |
[istream.formatted]: input.md#istream.formatted
|
| 8958 |
[lessthancomparable]: #lessthancomparable
|
| 8959 |
[logical.operations]: #logical.operations
|
|
|
|
| 9039 |
[time.duration]: #time.duration
|
| 9040 |
[time.duration.arithmetic]: #time.duration.arithmetic
|
| 9041 |
[time.duration.cast]: #time.duration.cast
|
| 9042 |
[time.duration.comparisons]: #time.duration.comparisons
|
| 9043 |
[time.duration.cons]: #time.duration.cons
|
| 9044 |
+
[time.duration.literals]: #time.duration.literals
|
| 9045 |
[time.duration.nonmember]: #time.duration.nonmember
|
| 9046 |
[time.duration.observer]: #time.duration.observer
|
| 9047 |
[time.duration.special]: #time.duration.special
|
| 9048 |
[time.general]: #time.general
|
| 9049 |
[time.point]: #time.point
|
|
|
|
| 9078 |
[type.index.synopsis]: #type.index.synopsis
|
| 9079 |
[uninitialized.copy]: #uninitialized.copy
|
| 9080 |
[uninitialized.fill]: #uninitialized.fill
|
| 9081 |
[uninitialized.fill.n]: #uninitialized.fill.n
|
| 9082 |
[unique.ptr]: #unique.ptr
|
| 9083 |
+
[unique.ptr.create]: #unique.ptr.create
|
| 9084 |
[unique.ptr.dltr]: #unique.ptr.dltr
|
| 9085 |
[unique.ptr.dltr.dflt]: #unique.ptr.dltr.dflt
|
| 9086 |
[unique.ptr.dltr.dflt1]: #unique.ptr.dltr.dflt1
|
| 9087 |
[unique.ptr.dltr.general]: #unique.ptr.dltr.general
|
| 9088 |
[unique.ptr.runtime]: #unique.ptr.runtime
|
|
|
|
| 9125 |
[util.smartptr.weak.spec]: #util.smartptr.weak.spec
|
| 9126 |
[util.smartptr.weakptr]: #util.smartptr.weakptr
|
| 9127 |
[utilities]: #utilities
|
| 9128 |
[utilities.general]: #utilities.general
|
| 9129 |
[utility]: #utility
|
| 9130 |
+
[utility.exchange]: #utility.exchange
|
| 9131 |
[utility.swap]: #utility.swap
|
| 9132 |
|
| 9133 |
[^1]: `pointer_safety::preferred` might be returned to indicate that a
|
| 9134 |
leak detector is running so that the program can avoid spurious leak
|
| 9135 |
reports.
|