- tmp/tmpgdotz56m/{from.md → to.md} +383 -175
tmp/tmpgdotz56m/{from.md → to.md}
RENAMED
|
@@ -26,44 +26,64 @@ namespace std {
|
|
| 26 |
|
| 27 |
template <class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
|
| 28 |
template <class T> reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
|
| 29 |
|
| 30 |
// [arithmetic.operations], arithmetic operations:
|
| 31 |
-
template <class T> struct plus;
|
| 32 |
-
template <class T> struct minus;
|
| 33 |
-
template <class T> struct multiplies;
|
| 34 |
-
template <class T> struct divides;
|
| 35 |
-
template <class T> struct modulus;
|
| 36 |
-
template <class T> struct negate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
// [comparisons], comparisons:
|
| 39 |
-
template <class T> struct equal_to;
|
| 40 |
-
template <class T> struct not_equal_to;
|
| 41 |
-
template <class T> struct greater;
|
| 42 |
-
template <class T> struct less;
|
| 43 |
-
template <class T> struct greater_equal;
|
| 44 |
-
template <class T> struct less_equal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
// [logical.operations], logical operations:
|
| 47 |
-
template <class T> struct logical_and;
|
| 48 |
-
template <class T> struct logical_or;
|
| 49 |
-
template <class T> struct logical_not;
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
// [bitwise.operations], bitwise operations:
|
| 52 |
-
template <class T> struct bit_and;
|
| 53 |
-
template <class T> struct bit_or;
|
| 54 |
-
template <class T> struct bit_xor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
// [negators], negators:
|
| 57 |
template <class Predicate> class unary_negate;
|
| 58 |
template <class Predicate>
|
| 59 |
-
unary_negate<Predicate>
|
| 60 |
template <class Predicate> class binary_negate;
|
| 61 |
template <class Predicate>
|
| 62 |
-
binary_negate<Predicate> not2(const Predicate&);
|
| 63 |
|
| 64 |
-
// [bind], bind:
|
| 65 |
template<class T> struct is_bind_expression;
|
| 66 |
template<class T> struct is_placeholder;
|
| 67 |
|
| 68 |
template<class F, class... BoundArgs>
|
| 69 |
unspecified bind(F&&, BoundArgs&&...);
|
|
@@ -125,34 +145,10 @@ namespace std {
|
|
| 125 |
template <class S, class T, class A>
|
| 126 |
const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
|
| 127 |
|
| 128 |
// [func.memfn], member function adaptors:
|
| 129 |
template<class R, class T> unspecified mem_fn(R T::*);
|
| 130 |
-
template<class R, class T, class... Args>
|
| 131 |
-
unspecified mem_fn(R (T::*)(Args...));
|
| 132 |
-
template<class R, class T, class... Args>
|
| 133 |
-
unspecified mem_fn(R (T::*)(Args...) const);
|
| 134 |
-
template<class R, class T, class... Args>
|
| 135 |
-
unspecified mem_fn(R (T::*)(Args...) volatile);
|
| 136 |
-
template<class R, class T, class... Args>
|
| 137 |
-
unspecified mem_fn(R (T::*)(Args...) const volatile);
|
| 138 |
-
template<class R, class T, class... Args>
|
| 139 |
-
unspecified mem_fn(R (T::*)(Args...) &);
|
| 140 |
-
template<class R, class T, class... Args>
|
| 141 |
-
unspecified mem_fn(R (T::*)(Args...) const &);
|
| 142 |
-
template<class R, class T, class... Args>
|
| 143 |
-
unspecified mem_fn(R (T::*)(Args...) volatile &);
|
| 144 |
-
template<class R, class T, class... Args>
|
| 145 |
-
unspecified mem_fn(R (T::*)(Args...) const volatile &);
|
| 146 |
-
template<class R, class T, class... Args>
|
| 147 |
-
unspecified mem_fn(R (T::*)(Args...) &&);
|
| 148 |
-
template<class R, class T, class... Args>
|
| 149 |
-
unspecified mem_fn(R (T::*)(Args...) const &&);
|
| 150 |
-
template<class R, class T, class... Args>
|
| 151 |
-
unspecified mem_fn(R (T::*)(Args...) volatile &&);
|
| 152 |
-
template<class R, class T, class... Args>
|
| 153 |
-
unspecified mem_fn(R (T::*)(Args...) const volatile &&);
|
| 154 |
|
| 155 |
// [func.wrap] polymorphic function wrappers:
|
| 156 |
class bad_function_call;
|
| 157 |
|
| 158 |
template<class> class function; // undefined
|
|
@@ -168,11 +164,11 @@ namespace std {
|
|
| 168 |
template<class R, class... ArgTypes>
|
| 169 |
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
|
| 170 |
template<class R, class... ArgTypes>
|
| 171 |
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
|
| 172 |
|
| 173 |
-
// [unord.hash], hash function
|
| 174 |
template <class T> struct hash;
|
| 175 |
|
| 176 |
// Hash function specializations
|
| 177 |
template <> struct hash<bool>;
|
| 178 |
template <> struct hash<char>;
|
|
@@ -210,15 +206,15 @@ To negate every element of `a`:
|
|
| 210 |
``` cpp
|
| 211 |
transform(a.begin(), a.end(), a.begin(), negate<double>());
|
| 212 |
```
|
| 213 |
|
| 214 |
To enable adaptors and other components to manipulate function objects
|
| 215 |
-
that take one or two arguments
|
| 216 |
-
correspondingly provide typedefs `argument_type` and
|
| 217 |
-
function objects that take one argument and
|
| 218 |
-
`second_argument_type`, and `result_type` for
|
| 219 |
-
two arguments.
|
| 220 |
|
| 221 |
### Definitions <a id="func.def">[[func.def]]</a>
|
| 222 |
|
| 223 |
The following definitions apply to this Clause:
|
| 224 |
|
|
@@ -301,22 +297,22 @@ namespace std {
|
|
| 301 |
typedef see below second_argument_type; // not always defined
|
| 302 |
|
| 303 |
// construct/copy/destroy
|
| 304 |
reference_wrapper(T&) noexcept;
|
| 305 |
reference_wrapper(T&&) = delete; // do not bind to temporary objects
|
| 306 |
-
reference_wrapper(const reference_wrapper
|
| 307 |
|
| 308 |
// assignment
|
| 309 |
-
reference_wrapper& operator=(const reference_wrapper
|
| 310 |
|
| 311 |
// access
|
| 312 |
operator T& () const noexcept;
|
| 313 |
T& get() const noexcept;
|
| 314 |
|
| 315 |
// invocation
|
| 316 |
template <class... ArgTypes>
|
| 317 |
-
|
| 318 |
operator() (ArgTypes&&...) const;
|
| 319 |
};
|
| 320 |
}
|
| 321 |
```
|
| 322 |
|
|
@@ -325,11 +321,11 @@ wrapper around a reference to an object or function of type `T`.
|
|
| 325 |
|
| 326 |
`reference_wrapper<T>` has a weak result type ([[func.require]]). If
|
| 327 |
`T` is a function type, `result_type` shall be a synonym for the return
|
| 328 |
type of `T`.
|
| 329 |
|
| 330 |
-
The template
|
| 331 |
type named `argument_type` as a synonym for `T1` only if the type `T` is
|
| 332 |
any of the following:
|
| 333 |
|
| 334 |
- a function type or a pointer to function type taking one argument of
|
| 335 |
type `T1`
|
|
@@ -346,11 +342,11 @@ the following:
|
|
| 346 |
- a function type or a pointer to function type taking two arguments of
|
| 347 |
types `T1` and `T2`
|
| 348 |
- a pointer to member function `R T0::f(T2)` *cv* (where *cv* represents
|
| 349 |
the member function’s cv-qualifiers); the type `T1` is *cv* `T0*`
|
| 350 |
- a class type with member types `first_argument_type` and
|
| 351 |
-
`second_argument_type`; the type `T1` is `T::first_argument_type`
|
| 352 |
the type `T2` is `T::second_argument_type`.
|
| 353 |
|
| 354 |
#### `reference_wrapper` construct/copy/destroy <a id="refwrap.const">[[refwrap.const]]</a>
|
| 355 |
|
| 356 |
``` cpp
|
|
@@ -359,20 +355,20 @@ reference_wrapper(T& t) noexcept;
|
|
| 359 |
|
| 360 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 361 |
reference to `t`.
|
| 362 |
|
| 363 |
``` cpp
|
| 364 |
-
reference_wrapper(const reference_wrapper
|
| 365 |
```
|
| 366 |
|
| 367 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 368 |
reference to `x.get()`.
|
| 369 |
|
| 370 |
#### `reference_wrapper` assignment <a id="refwrap.assign">[[refwrap.assign]]</a>
|
| 371 |
|
| 372 |
``` cpp
|
| 373 |
-
reference_wrapper& operator=(const reference_wrapper
|
| 374 |
```
|
| 375 |
|
| 376 |
*Postconditions:* `*this` stores a reference to `x.get()`.
|
| 377 |
|
| 378 |
#### `reference_wrapper` access <a id="refwrap.access">[[refwrap.access]]</a>
|
|
@@ -391,11 +387,11 @@ T& get() const noexcept;
|
|
| 391 |
|
| 392 |
#### reference_wrapper invocation <a id="refwrap.invoke">[[refwrap.invoke]]</a>
|
| 393 |
|
| 394 |
``` cpp
|
| 395 |
template <class... ArgTypes>
|
| 396 |
-
|
| 397 |
operator()(ArgTypes&&... args) const;
|
| 398 |
```
|
| 399 |
|
| 400 |
*Returns:*
|
| 401 |
*`INVOKE`*`(get(), std::forward<ArgTypes>(args)...)`. ([[func.require]])
|
|
@@ -435,145 +431,277 @@ template <class T> reference_wrapper<const T> cref(reference_wrapper<T> t) noexc
|
|
| 435 |
|
| 436 |
The library provides basic function object classes for all of the
|
| 437 |
arithmetic operators in the language ([[expr.mul]], [[expr.add]]).
|
| 438 |
|
| 439 |
``` cpp
|
| 440 |
-
template <class T> struct plus {
|
| 441 |
-
T operator()(const T& x, const T& y) const;
|
| 442 |
typedef T first_argument_type;
|
| 443 |
typedef T second_argument_type;
|
| 444 |
typedef T result_type;
|
| 445 |
};
|
| 446 |
```
|
| 447 |
|
| 448 |
`operator()` returns `x + y`.
|
| 449 |
|
| 450 |
``` cpp
|
| 451 |
-
template <class T> struct minus {
|
| 452 |
-
T operator()(const T& x, const T& y) const;
|
| 453 |
typedef T first_argument_type;
|
| 454 |
typedef T second_argument_type;
|
| 455 |
typedef T result_type;
|
| 456 |
};
|
| 457 |
```
|
| 458 |
|
| 459 |
`operator()` returns `x - y`.
|
| 460 |
|
| 461 |
``` cpp
|
| 462 |
-
template <class T> struct multiplies {
|
| 463 |
-
T operator()(const T& x, const T& y) const;
|
| 464 |
typedef T first_argument_type;
|
| 465 |
typedef T second_argument_type;
|
| 466 |
typedef T result_type;
|
| 467 |
};
|
| 468 |
```
|
| 469 |
|
| 470 |
`operator()` returns `x * y`.
|
| 471 |
|
| 472 |
``` cpp
|
| 473 |
-
template <class T> struct divides {
|
| 474 |
-
T operator()(const T& x, const T& y) const;
|
| 475 |
typedef T first_argument_type;
|
| 476 |
typedef T second_argument_type;
|
| 477 |
typedef T result_type;
|
| 478 |
};
|
| 479 |
```
|
| 480 |
|
| 481 |
`operator()` returns `x / y`.
|
| 482 |
|
| 483 |
``` cpp
|
| 484 |
-
template <class T> struct modulus {
|
| 485 |
-
T operator()(const T& x, const T& y) const;
|
| 486 |
typedef T first_argument_type;
|
| 487 |
typedef T second_argument_type;
|
| 488 |
typedef T result_type;
|
| 489 |
};
|
| 490 |
```
|
| 491 |
|
| 492 |
`operator()` returns `x % y`.
|
| 493 |
|
| 494 |
``` cpp
|
| 495 |
-
template <class T> struct negate {
|
| 496 |
-
T operator()(const T& x) const;
|
| 497 |
typedef T argument_type;
|
| 498 |
typedef T result_type;
|
| 499 |
};
|
| 500 |
```
|
| 501 |
|
| 502 |
`operator()` returns `-x`.
|
| 503 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
### Comparisons <a id="comparisons">[[comparisons]]</a>
|
| 505 |
|
| 506 |
The library provides basic function object classes for all of the
|
| 507 |
comparison operators in the language ([[expr.rel]], [[expr.eq]]).
|
| 508 |
|
| 509 |
``` cpp
|
| 510 |
-
template <class T> struct equal_to {
|
| 511 |
-
bool operator()(const T& x, const T& y) const;
|
| 512 |
typedef T first_argument_type;
|
| 513 |
typedef T second_argument_type;
|
| 514 |
typedef bool result_type;
|
| 515 |
};
|
| 516 |
```
|
| 517 |
|
| 518 |
`operator()` returns `x == y`.
|
| 519 |
|
| 520 |
``` cpp
|
| 521 |
-
template <class T> struct not_equal_to {
|
| 522 |
-
bool operator()(const T& x, const T& y) const;
|
| 523 |
typedef T first_argument_type;
|
| 524 |
typedef T second_argument_type;
|
| 525 |
typedef bool result_type;
|
| 526 |
};
|
| 527 |
```
|
| 528 |
|
| 529 |
`operator()` returns `x != y`.
|
| 530 |
|
| 531 |
``` cpp
|
| 532 |
-
template <class T> struct greater {
|
| 533 |
-
bool operator()(const T& x, const T& y) const;
|
| 534 |
typedef T first_argument_type;
|
| 535 |
typedef T second_argument_type;
|
| 536 |
typedef bool result_type;
|
| 537 |
};
|
| 538 |
```
|
| 539 |
|
| 540 |
`operator()` returns `x > y`.
|
| 541 |
|
| 542 |
``` cpp
|
| 543 |
-
template <class T> struct less {
|
| 544 |
-
bool operator()(const T& x, const T& y) const;
|
| 545 |
typedef T first_argument_type;
|
| 546 |
typedef T second_argument_type;
|
| 547 |
typedef bool result_type;
|
| 548 |
};
|
| 549 |
```
|
| 550 |
|
| 551 |
`operator()` returns `x < y`.
|
| 552 |
|
| 553 |
``` cpp
|
| 554 |
-
template <class T> struct greater_equal {
|
| 555 |
-
bool operator()(const T& x, const T& y) const;
|
| 556 |
typedef T first_argument_type;
|
| 557 |
typedef T second_argument_type;
|
| 558 |
typedef bool result_type;
|
| 559 |
};
|
| 560 |
```
|
| 561 |
|
| 562 |
`operator()` returns `x >= y`.
|
| 563 |
|
| 564 |
``` cpp
|
| 565 |
-
template <class T> struct less_equal {
|
| 566 |
-
bool operator()(const T& x, const T& y) const;
|
| 567 |
typedef T first_argument_type;
|
| 568 |
typedef T second_argument_type;
|
| 569 |
typedef bool result_type;
|
| 570 |
};
|
| 571 |
```
|
| 572 |
|
| 573 |
`operator()` returns `x <= y`.
|
| 574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
For templates `greater`, `less`, `greater_equal`, and `less_equal`, the
|
| 576 |
specializations for any pointer type yield a total order, even if the
|
| 577 |
built-in operators `<`, `>`, `<=`, `>=` do not.
|
| 578 |
|
| 579 |
### Logical operations <a id="logical.operations">[[logical.operations]]</a>
|
|
@@ -581,111 +709,198 @@ built-in operators `<`, `>`, `<=`, `>=` do not.
|
|
| 581 |
The library provides basic function object classes for all of the
|
| 582 |
logical operators in the language ([[expr.log.and]], [[expr.log.or]],
|
| 583 |
[[expr.unary.op]]).
|
| 584 |
|
| 585 |
``` cpp
|
| 586 |
-
template <class T> struct logical_and {
|
| 587 |
-
bool operator()(const T& x, const T& y) const;
|
| 588 |
typedef T first_argument_type;
|
| 589 |
typedef T second_argument_type;
|
| 590 |
typedef bool result_type;
|
| 591 |
};
|
| 592 |
```
|
| 593 |
|
| 594 |
`operator()` returns `x && y`.
|
| 595 |
|
| 596 |
``` cpp
|
| 597 |
-
template <class T> struct logical_or {
|
| 598 |
-
bool operator()(const T& x, const T& y) const;
|
| 599 |
typedef T first_argument_type;
|
| 600 |
typedef T second_argument_type;
|
| 601 |
typedef bool result_type;
|
| 602 |
};
|
| 603 |
```
|
| 604 |
|
| 605 |
`operator()` returns `x || y`.
|
| 606 |
|
| 607 |
``` cpp
|
| 608 |
-
template <class T> struct logical_not {
|
| 609 |
-
bool operator()(const T& x) const;
|
| 610 |
typedef T argument_type;
|
| 611 |
typedef bool result_type;
|
| 612 |
};
|
| 613 |
```
|
| 614 |
|
| 615 |
`operator()` returns `!x`.
|
| 616 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 617 |
### Bitwise operations <a id="bitwise.operations">[[bitwise.operations]]</a>
|
| 618 |
|
| 619 |
The library provides basic function object classes for all of the
|
| 620 |
bitwise operators in the language ([[expr.bit.and]], [[expr.or]],
|
| 621 |
-
[[expr.xor]]).
|
| 622 |
|
| 623 |
``` cpp
|
| 624 |
-
template <class T> struct bit_and {
|
| 625 |
-
T operator()(const T& x, const T& y) const;
|
| 626 |
typedef T first_argument_type;
|
| 627 |
typedef T second_argument_type;
|
| 628 |
typedef T result_type;
|
| 629 |
};
|
| 630 |
```
|
| 631 |
|
| 632 |
`operator()` returns `x & y`.
|
| 633 |
|
| 634 |
``` cpp
|
| 635 |
-
template <class T> struct bit_or {
|
| 636 |
-
T operator()(const T& x, const T& y) const;
|
| 637 |
typedef T first_argument_type;
|
| 638 |
typedef T second_argument_type;
|
| 639 |
typedef T result_type;
|
| 640 |
};
|
| 641 |
```
|
| 642 |
|
| 643 |
`operator()` returns `x | y`.
|
| 644 |
|
| 645 |
``` cpp
|
| 646 |
-
template <class T> struct bit_xor {
|
| 647 |
-
T operator()(const T& x, const T& y) const;
|
| 648 |
typedef T first_argument_type;
|
| 649 |
typedef T second_argument_type;
|
| 650 |
typedef T result_type;
|
| 651 |
};
|
| 652 |
```
|
| 653 |
|
| 654 |
`operator()` returns `x ^ y`.
|
| 655 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 656 |
### Negators <a id="negators">[[negators]]</a>
|
| 657 |
|
| 658 |
Negators `not1` and `not2` take a unary and a binary predicate,
|
| 659 |
respectively, and return their complements ([[expr.unary.op]]).
|
| 660 |
|
| 661 |
``` cpp
|
| 662 |
template <class Predicate>
|
| 663 |
class unary_negate {
|
| 664 |
public:
|
| 665 |
-
explicit unary_negate(const Predicate& pred);
|
| 666 |
-
bool operator()(const typename Predicate::argument_type& x) const;
|
| 667 |
typedef typename Predicate::argument_type argument_type;
|
| 668 |
typedef bool result_type;
|
| 669 |
};
|
| 670 |
```
|
| 671 |
|
| 672 |
`operator()` returns `!pred(x)`.
|
| 673 |
|
| 674 |
``` cpp
|
| 675 |
template <class Predicate>
|
| 676 |
-
unary_negate<Predicate> not1(const Predicate& pred);
|
| 677 |
```
|
| 678 |
|
| 679 |
*Returns:* `unary_negate<Predicate>(pred)`.
|
| 680 |
|
| 681 |
``` cpp
|
| 682 |
template <class Predicate>
|
| 683 |
class binary_negate {
|
| 684 |
public:
|
| 685 |
-
explicit binary_negate(const Predicate& pred);
|
| 686 |
-
bool operator()(const typename Predicate::first_argument_type&
|
| 687 |
const typename Predicate::second_argument_type& y) const;
|
| 688 |
typedef typename Predicate::first_argument_type first_argument_type;
|
| 689 |
typedef typename Predicate::second_argument_type second_argument_type;
|
| 690 |
typedef bool result_type;
|
| 691 |
};
|
|
@@ -693,60 +908,70 @@ template <class Predicate>
|
|
| 693 |
|
| 694 |
`operator()` returns `!pred(x,y)`.
|
| 695 |
|
| 696 |
``` cpp
|
| 697 |
template <class Predicate>
|
| 698 |
-
binary_negate<Predicate> not2(const Predicate& pred);
|
| 699 |
```
|
| 700 |
|
| 701 |
*Returns:* `binary_negate<Predicate>(pred)`.
|
| 702 |
|
| 703 |
-
### Function
|
| 704 |
-
|
| 705 |
-
The function template `bind` returns an object that binds a callable
|
| 706 |
-
object passed as an argument to additional arguments.
|
| 707 |
-
|
| 708 |
-
#### Function object binders <a id="func.bind">[[func.bind]]</a>
|
| 709 |
|
| 710 |
This subclause describes a uniform mechanism for binding arguments of
|
| 711 |
callable objects.
|
| 712 |
|
| 713 |
-
####
|
| 714 |
|
| 715 |
``` cpp
|
| 716 |
namespace std {
|
| 717 |
-
template<class T> struct is_bind_expression
|
| 718 |
-
: integral_constant<bool, see below> { };
|
| 719 |
}
|
| 720 |
```
|
| 721 |
|
| 722 |
`is_bind_expression` can be used to detect function objects generated by
|
| 723 |
-
`bind`. `bind` uses `is_bind_expression` to detect subexpressions.
|
| 724 |
-
may specialize this template to indicate that a type should be treated
|
| 725 |
-
as a subexpression in a `bind` call.
|
| 726 |
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 730 |
|
| 731 |
`is_placeholder` can be used to detect the standard placeholders `_1`,
|
| 732 |
`_2`, and so on. `bind` uses `is_placeholder` to detect placeholders.
|
| 733 |
-
Users may specialize this template to indicate a placeholder type.
|
| 734 |
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
|
| 739 |
-
####
|
| 740 |
|
| 741 |
In the text that follows, the following names have the following
|
| 742 |
meanings:
|
| 743 |
|
| 744 |
-
- `FD` is the type `
|
| 745 |
- `fd` is an lvalue of type `FD` constructed from `std::forward<F>(f)`,
|
| 746 |
-
- `Ti` is the iᵗʰ type in the template parameter
|
| 747 |
-
- `TiD` is the type `
|
| 748 |
- `ti` is the iᵗʰ argument in the function parameter pack `bound_args`,
|
| 749 |
- `tid` is an lvalue of type `TiD` constructed from
|
| 750 |
`std::forward<Ti>(ti)`,
|
| 751 |
- `Uj` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
|
| 752 |
the forwarding call wrapper, and
|
|
@@ -763,11 +988,11 @@ template<class F, class... BoundArgs>
|
|
| 763 |
expression for some values *w1, w2, ..., wN*, where
|
| 764 |
`N == sizeof...(bound_args)`.
|
| 765 |
|
| 766 |
*Returns:* A forwarding call wrapper `g` with a weak result
|
| 767 |
type ([[func.require]]). The effect of `g(u1, u2, ..., uM)` shall be
|
| 768 |
-
*`INVOKE`*`(fd, v1, v2, ..., vN,
|
| 769 |
where *`cv`* represents the *cv*-qualifiers of `g` and the values and
|
| 770 |
types of the bound arguments `v1, v2, ..., vN` are determined as
|
| 771 |
specified below. The copy constructor and move constructor of the
|
| 772 |
forwarding call wrapper shall throw an exception if and only if the
|
| 773 |
corresponding constructor of `FD` or of any of the types `TiD` throws an
|
|
@@ -792,11 +1017,12 @@ template<class R, class F, class... BoundArgs>
|
|
| 792 |
*`INVOKE`*`(fd, w1, w2, ..., wN)` shall be a valid expression for some
|
| 793 |
values *w1, w2, ..., wN*, where `N == sizeof...(bound_args)`.
|
| 794 |
|
| 795 |
*Returns:* A forwarding call wrapper `g` with a nested type
|
| 796 |
`result_type` defined as a synonym for `R`. The effect of
|
| 797 |
-
`g(u1, u2, ..., uM)` shall be
|
|
|
|
| 798 |
where the values and types of the bound arguments `v1, v2, ..., vN` are
|
| 799 |
determined as specified below. The copy constructor and move constructor
|
| 800 |
of the forwarding call wrapper shall throw an exception if and only if
|
| 801 |
the corresponding constructor of `FD` or of any of the types `TiD`
|
| 802 |
throws an exception.
|
|
@@ -817,16 +1043,16 @@ from the call to `bind` and the *cv*-qualifiers *cv* of the call wrapper
|
|
| 817 |
|
| 818 |
- if `TiD` is `reference_wrapper<T>`, the argument is `tid.get()` and
|
| 819 |
its type `Vi` is `T&`;
|
| 820 |
- if the value of `is_bind_expression<TiD>::value` is `true`, the
|
| 821 |
argument is `tid(std::forward<Uj>({}uj)...)` and its type `Vi` is
|
| 822 |
-
`
|
| 823 |
- if the value `j` of `is_placeholder<TiD>::value` is not zero, the
|
| 824 |
argument is `std::forward<Uj>(uj)` and its type `Vi` is `Uj&&`;
|
| 825 |
- otherwise, the value is `tid` and its type `Vi` is `TiD cv &`.
|
| 826 |
|
| 827 |
-
####
|
| 828 |
|
| 829 |
``` cpp
|
| 830 |
namespace std {
|
| 831 |
namespace placeholders {
|
| 832 |
// M is the implementation-defined number of placeholders
|
|
@@ -847,36 +1073,11 @@ whether placeholder types are `CopyAssignable`. `CopyAssignable`
|
|
| 847 |
placeholders’ copy assignment operators shall not throw exceptions.
|
| 848 |
|
| 849 |
### Function template `mem_fn` <a id="func.memfn">[[func.memfn]]</a>
|
| 850 |
|
| 851 |
``` cpp
|
| 852 |
-
template<class R, class T>
|
| 853 |
-
unspecified mem_fn(R T::* pm);
|
| 854 |
-
template<class R, class T, class... Args>
|
| 855 |
-
unspecified mem_fn(R (T::* pm)(Args...));
|
| 856 |
-
template<class R, class T, class... Args>
|
| 857 |
-
unspecified mem_fn(R (T::* pm)(Args...) const);
|
| 858 |
-
template<class R, class T, class... Args>
|
| 859 |
-
unspecified mem_fn(R (T::* pm)(Args...) volatile);
|
| 860 |
-
template<class R, class T, class... Args>
|
| 861 |
-
unspecified mem_fn(R (T::* pm)(Args...) const volatile);
|
| 862 |
-
template<class R, class T, class... Args>
|
| 863 |
-
unspecified mem_fn(R (T::* pm)(Args...) &);
|
| 864 |
-
template<class R, class T, class... Args>
|
| 865 |
-
unspecified mem_fn(R (T::* pm)(Args...) const &);
|
| 866 |
-
template<class R, class T, class... Args>
|
| 867 |
-
unspecified mem_fn(R (T::* pm)(Args...) volatile &);
|
| 868 |
-
template<class R, class T, class... Args>
|
| 869 |
-
unspecified mem_fn(R (T::* pm)(Args...) const volatile &);
|
| 870 |
-
template<class R, class T, class... Args>
|
| 871 |
-
unspecified mem_fn(R (T::* pm)(Args...) &&);
|
| 872 |
-
template<class R, class T, class... Args>
|
| 873 |
-
unspecified mem_fn(R (T::* pm)(Args...) const &&);
|
| 874 |
-
template<class R, class T, class... Args>
|
| 875 |
-
unspecified mem_fn(R (T::* pm)(Args...) volatile &&);
|
| 876 |
-
template<class R, class T, class... Args>
|
| 877 |
-
unspecified mem_fn(R (T::* pm)(Args...) const volatile &&);
|
| 878 |
```
|
| 879 |
|
| 880 |
*Returns:* A simple call wrapper ([[func.def]]) `fn` such that the
|
| 881 |
expression `fn(t, a2, ..., aN)` is equivalent to
|
| 882 |
*`INVOKE`*`(pm, t, a2, ..., aN)` ([[func.require]]). `fn` shall have a
|
|
@@ -934,15 +1135,15 @@ namespace std {
|
|
| 934 |
|
| 935 |
template<class R, class... ArgTypes>
|
| 936 |
class function<R(ArgTypes...)> {
|
| 937 |
public:
|
| 938 |
typedef R result_type;
|
| 939 |
-
typedef T1 argument_type; //
|
| 940 |
// the type in ArgTypes is T1
|
| 941 |
-
typedef T1 first_argument_type; //
|
| 942 |
// ArgTypes contains T1 and T2
|
| 943 |
-
typedef T2 second_argument_type; //
|
| 944 |
// ArgTypes contains T1 and T2
|
| 945 |
|
| 946 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 947 |
function() noexcept;
|
| 948 |
function(nullptr_t) noexcept;
|
|
@@ -976,12 +1177,12 @@ namespace std {
|
|
| 976 |
// [func.wrap.func.inv], function invocation:
|
| 977 |
R operator()(ArgTypes...) const;
|
| 978 |
|
| 979 |
// [func.wrap.func.targ], function target access:
|
| 980 |
const std::type_info& target_type() const noexcept;
|
| 981 |
-
template
|
| 982 |
-
template
|
| 983 |
|
| 984 |
};
|
| 985 |
|
| 986 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 987 |
template <class R, class... ArgTypes>
|
|
@@ -1070,20 +1271,21 @@ state with an unspecified value.
|
|
| 1070 |
``` cpp
|
| 1071 |
template<class F> function(F f);
|
| 1072 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 1073 |
```
|
| 1074 |
|
| 1075 |
-
*Requires:* `F` shall be `CopyConstructible`.
|
| 1076 |
-
|
| 1077 |
-
|
| 1078 |
-
|
|
|
|
| 1079 |
|
| 1080 |
*Postconditions:* `!*this` if any of the following hold:
|
| 1081 |
|
| 1082 |
-
- `f` is a
|
| 1083 |
-
- `f` is a
|
| 1084 |
-
- `F` is an instance of the `function` class template, and `!f`
|
| 1085 |
|
| 1086 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 1087 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 1088 |
dynamically allocated memory for small callable objects, for example,
|
| 1089 |
where `f`’s target is an object holding only a pointer or reference to
|
|
@@ -1111,11 +1313,11 @@ function& operator=(function&& f);
|
|
| 1111 |
|
| 1112 |
``` cpp
|
| 1113 |
function& operator=(nullptr_t);
|
| 1114 |
```
|
| 1115 |
|
| 1116 |
-
*Effects:* If `*this !=
|
| 1117 |
|
| 1118 |
*Postconditions:* `!(*this)`.
|
| 1119 |
|
| 1120 |
*Returns:* `*this`
|
| 1121 |
|
|
@@ -1125,10 +1327,15 @@ template<class F> function& operator=(F&& f);
|
|
| 1125 |
|
| 1126 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 1127 |
|
| 1128 |
*Returns:* `*this`
|
| 1129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1130 |
``` cpp
|
| 1131 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 1132 |
```
|
| 1133 |
|
| 1134 |
*Effects:* `function(f).swap(*this);`
|
|
@@ -1137,11 +1344,11 @@ template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
|
| 1137 |
|
| 1138 |
``` cpp
|
| 1139 |
~function();
|
| 1140 |
```
|
| 1141 |
|
| 1142 |
-
*Effects:* If `*this !=
|
| 1143 |
|
| 1144 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 1145 |
|
| 1146 |
``` cpp
|
| 1147 |
void swap(function& other) noexcept;
|
|
@@ -1188,18 +1395,18 @@ const std::type_info& target_type() const noexcept;
|
|
| 1188 |
|
| 1189 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 1190 |
`typeid(void)`.
|
| 1191 |
|
| 1192 |
``` cpp
|
| 1193 |
-
template<
|
| 1194 |
-
template<
|
| 1195 |
```
|
| 1196 |
|
| 1197 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 1198 |
for parameter types `ArgTypes` and return type `R`.
|
| 1199 |
|
| 1200 |
-
*Returns:* If `
|
| 1201 |
function target; otherwise a null pointer.
|
| 1202 |
|
| 1203 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 1204 |
|
| 1205 |
``` cpp
|
|
@@ -1232,11 +1439,12 @@ template<class R, class... ArgTypes>
|
|
| 1232 |
### Class template `hash` <a id="unord.hash">[[unord.hash]]</a>
|
| 1233 |
|
| 1234 |
The unordered associative containers defined in [[unord]] use
|
| 1235 |
specializations of the class template `hash` as the default hash
|
| 1236 |
function. For all object types `Key` for which there exists a
|
| 1237 |
-
specialization `hash<Key>`,
|
|
|
|
| 1238 |
|
| 1239 |
- satisfy the `Hash` requirements ([[hash.requirements]]), with `Key`
|
| 1240 |
as the function call argument type, the `DefaultConstructible`
|
| 1241 |
requirements (Table [[defaultconstructible]]), the `CopyAssignable`
|
| 1242 |
requirements (Table [[copyassignable]]),
|
|
@@ -1271,8 +1479,8 @@ template <> struct hash<float>;
|
|
| 1271 |
template <> struct hash<double>;
|
| 1272 |
template <> struct hash<long double>;
|
| 1273 |
template <class T> struct hash<T*>;
|
| 1274 |
```
|
| 1275 |
|
| 1276 |
-
|
| 1277 |
-
|
| 1278 |
|
|
|
|
| 26 |
|
| 27 |
template <class T> reference_wrapper<T> ref(reference_wrapper<T>) noexcept;
|
| 28 |
template <class T> reference_wrapper<const T> cref(reference_wrapper<T>) noexcept;
|
| 29 |
|
| 30 |
// [arithmetic.operations], arithmetic operations:
|
| 31 |
+
template <class T = void> struct plus;
|
| 32 |
+
template <class T = void> struct minus;
|
| 33 |
+
template <class T = void> struct multiplies;
|
| 34 |
+
template <class T = void> struct divides;
|
| 35 |
+
template <class T = void> struct modulus;
|
| 36 |
+
template <class T = void> struct negate;
|
| 37 |
+
template <> struct plus<void>;
|
| 38 |
+
template <> struct minus<void>;
|
| 39 |
+
template <> struct multiplies<void>;
|
| 40 |
+
template <> struct divides<void>;
|
| 41 |
+
template <> struct modulus<void>;
|
| 42 |
+
template <> struct negate<void>;
|
| 43 |
|
| 44 |
// [comparisons], comparisons:
|
| 45 |
+
template <class T = void> struct equal_to;
|
| 46 |
+
template <class T = void> struct not_equal_to;
|
| 47 |
+
template <class T = void> struct greater;
|
| 48 |
+
template <class T = void> struct less;
|
| 49 |
+
template <class T = void> struct greater_equal;
|
| 50 |
+
template <class T = void> struct less_equal;
|
| 51 |
+
template <> struct equal_to<void>;
|
| 52 |
+
template <> struct not_equal_to<void>;
|
| 53 |
+
template <> struct greater<void>;
|
| 54 |
+
template <> struct less<void>;
|
| 55 |
+
template <> struct greater_equal<void>;
|
| 56 |
+
template <> struct less_equal<void>;
|
| 57 |
|
| 58 |
// [logical.operations], logical operations:
|
| 59 |
+
template <class T = void> struct logical_and;
|
| 60 |
+
template <class T = void> struct logical_or;
|
| 61 |
+
template <class T = void> struct logical_not;
|
| 62 |
+
template <> struct logical_and<void>;
|
| 63 |
+
template <> struct logical_or<void>;
|
| 64 |
+
template <> struct logical_not<void>;
|
| 65 |
|
| 66 |
// [bitwise.operations], bitwise operations:
|
| 67 |
+
template <class T = void> struct bit_and;
|
| 68 |
+
template <class T = void> struct bit_or;
|
| 69 |
+
template <class T = void> struct bit_xor;
|
| 70 |
+
template <class T = void> struct bit_not;
|
| 71 |
+
template <> struct bit_and<void>;
|
| 72 |
+
template <> struct bit_or<void>;
|
| 73 |
+
template <> struct bit_xor<void>;
|
| 74 |
+
template <> struct bit_not<void>;
|
| 75 |
|
| 76 |
// [negators], negators:
|
| 77 |
template <class Predicate> class unary_negate;
|
| 78 |
template <class Predicate>
|
| 79 |
+
constexpr unary_negate<Predicate> not1(const Predicate&);
|
| 80 |
template <class Predicate> class binary_negate;
|
| 81 |
template <class Predicate>
|
| 82 |
+
constexpr binary_negate<Predicate> not2(const Predicate&);
|
| 83 |
|
| 84 |
+
// [func.bind], bind:
|
| 85 |
template<class T> struct is_bind_expression;
|
| 86 |
template<class T> struct is_placeholder;
|
| 87 |
|
| 88 |
template<class F, class... BoundArgs>
|
| 89 |
unspecified bind(F&&, BoundArgs&&...);
|
|
|
|
| 145 |
template <class S, class T, class A>
|
| 146 |
const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
|
| 147 |
|
| 148 |
// [func.memfn], member function adaptors:
|
| 149 |
template<class R, class T> unspecified mem_fn(R T::*);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
// [func.wrap] polymorphic function wrappers:
|
| 152 |
class bad_function_call;
|
| 153 |
|
| 154 |
template<class> class function; // undefined
|
|
|
|
| 164 |
template<class R, class... ArgTypes>
|
| 165 |
bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
|
| 166 |
template<class R, class... ArgTypes>
|
| 167 |
bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
|
| 168 |
|
| 169 |
+
// [unord.hash], hash function primary template:
|
| 170 |
template <class T> struct hash;
|
| 171 |
|
| 172 |
// Hash function specializations
|
| 173 |
template <> struct hash<bool>;
|
| 174 |
template <> struct hash<char>;
|
|
|
|
| 206 |
``` cpp
|
| 207 |
transform(a.begin(), a.end(), a.begin(), negate<double>());
|
| 208 |
```
|
| 209 |
|
| 210 |
To enable adaptors and other components to manipulate function objects
|
| 211 |
+
that take one or two arguments many of the function objects in this
|
| 212 |
+
clause correspondingly provide typedefs `argument_type` and
|
| 213 |
+
`result_type` for function objects that take one argument and
|
| 214 |
+
`first_argument_type`, `second_argument_type`, and `result_type` for
|
| 215 |
+
function objects that take two arguments.
|
| 216 |
|
| 217 |
### Definitions <a id="func.def">[[func.def]]</a>
|
| 218 |
|
| 219 |
The following definitions apply to this Clause:
|
| 220 |
|
|
|
|
| 297 |
typedef see below second_argument_type; // not always defined
|
| 298 |
|
| 299 |
// construct/copy/destroy
|
| 300 |
reference_wrapper(T&) noexcept;
|
| 301 |
reference_wrapper(T&&) = delete; // do not bind to temporary objects
|
| 302 |
+
reference_wrapper(const reference_wrapper& x) noexcept;
|
| 303 |
|
| 304 |
// assignment
|
| 305 |
+
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 306 |
|
| 307 |
// access
|
| 308 |
operator T& () const noexcept;
|
| 309 |
T& get() const noexcept;
|
| 310 |
|
| 311 |
// invocation
|
| 312 |
template <class... ArgTypes>
|
| 313 |
+
result_of_t<T&(ArgTypes&&...)>
|
| 314 |
operator() (ArgTypes&&...) const;
|
| 315 |
};
|
| 316 |
}
|
| 317 |
```
|
| 318 |
|
|
|
|
| 321 |
|
| 322 |
`reference_wrapper<T>` has a weak result type ([[func.require]]). If
|
| 323 |
`T` is a function type, `result_type` shall be a synonym for the return
|
| 324 |
type of `T`.
|
| 325 |
|
| 326 |
+
The template specialization `reference_wrapper<T>` shall define a nested
|
| 327 |
type named `argument_type` as a synonym for `T1` only if the type `T` is
|
| 328 |
any of the following:
|
| 329 |
|
| 330 |
- a function type or a pointer to function type taking one argument of
|
| 331 |
type `T1`
|
|
|
|
| 342 |
- a function type or a pointer to function type taking two arguments of
|
| 343 |
types `T1` and `T2`
|
| 344 |
- a pointer to member function `R T0::f(T2)` *cv* (where *cv* represents
|
| 345 |
the member function’s cv-qualifiers); the type `T1` is *cv* `T0*`
|
| 346 |
- a class type with member types `first_argument_type` and
|
| 347 |
+
`second_argument_type`; the type `T1` is `T::first_argument_type` and
|
| 348 |
the type `T2` is `T::second_argument_type`.
|
| 349 |
|
| 350 |
#### `reference_wrapper` construct/copy/destroy <a id="refwrap.const">[[refwrap.const]]</a>
|
| 351 |
|
| 352 |
``` cpp
|
|
|
|
| 355 |
|
| 356 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 357 |
reference to `t`.
|
| 358 |
|
| 359 |
``` cpp
|
| 360 |
+
reference_wrapper(const reference_wrapper& x) noexcept;
|
| 361 |
```
|
| 362 |
|
| 363 |
*Effects:* Constructs a `reference_wrapper` object that stores a
|
| 364 |
reference to `x.get()`.
|
| 365 |
|
| 366 |
#### `reference_wrapper` assignment <a id="refwrap.assign">[[refwrap.assign]]</a>
|
| 367 |
|
| 368 |
``` cpp
|
| 369 |
+
reference_wrapper& operator=(const reference_wrapper& x) noexcept;
|
| 370 |
```
|
| 371 |
|
| 372 |
*Postconditions:* `*this` stores a reference to `x.get()`.
|
| 373 |
|
| 374 |
#### `reference_wrapper` access <a id="refwrap.access">[[refwrap.access]]</a>
|
|
|
|
| 387 |
|
| 388 |
#### reference_wrapper invocation <a id="refwrap.invoke">[[refwrap.invoke]]</a>
|
| 389 |
|
| 390 |
``` cpp
|
| 391 |
template <class... ArgTypes>
|
| 392 |
+
result_of_t<T&(ArgTypes&&... )>
|
| 393 |
operator()(ArgTypes&&... args) const;
|
| 394 |
```
|
| 395 |
|
| 396 |
*Returns:*
|
| 397 |
*`INVOKE`*`(get(), std::forward<ArgTypes>(args)...)`. ([[func.require]])
|
|
|
|
| 431 |
|
| 432 |
The library provides basic function object classes for all of the
|
| 433 |
arithmetic operators in the language ([[expr.mul]], [[expr.add]]).
|
| 434 |
|
| 435 |
``` cpp
|
| 436 |
+
template <class T = void> struct plus {
|
| 437 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 438 |
typedef T first_argument_type;
|
| 439 |
typedef T second_argument_type;
|
| 440 |
typedef T result_type;
|
| 441 |
};
|
| 442 |
```
|
| 443 |
|
| 444 |
`operator()` returns `x + y`.
|
| 445 |
|
| 446 |
``` cpp
|
| 447 |
+
template <class T = void> struct minus {
|
| 448 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 449 |
typedef T first_argument_type;
|
| 450 |
typedef T second_argument_type;
|
| 451 |
typedef T result_type;
|
| 452 |
};
|
| 453 |
```
|
| 454 |
|
| 455 |
`operator()` returns `x - y`.
|
| 456 |
|
| 457 |
``` cpp
|
| 458 |
+
template <class T = void> struct multiplies {
|
| 459 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 460 |
typedef T first_argument_type;
|
| 461 |
typedef T second_argument_type;
|
| 462 |
typedef T result_type;
|
| 463 |
};
|
| 464 |
```
|
| 465 |
|
| 466 |
`operator()` returns `x * y`.
|
| 467 |
|
| 468 |
``` cpp
|
| 469 |
+
template <class T = void> struct divides {
|
| 470 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 471 |
typedef T first_argument_type;
|
| 472 |
typedef T second_argument_type;
|
| 473 |
typedef T result_type;
|
| 474 |
};
|
| 475 |
```
|
| 476 |
|
| 477 |
`operator()` returns `x / y`.
|
| 478 |
|
| 479 |
``` cpp
|
| 480 |
+
template <class T = void> struct modulus {
|
| 481 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 482 |
typedef T first_argument_type;
|
| 483 |
typedef T second_argument_type;
|
| 484 |
typedef T result_type;
|
| 485 |
};
|
| 486 |
```
|
| 487 |
|
| 488 |
`operator()` returns `x % y`.
|
| 489 |
|
| 490 |
``` cpp
|
| 491 |
+
template <class T = void> struct negate {
|
| 492 |
+
constexpr T operator()(const T& x) const;
|
| 493 |
typedef T argument_type;
|
| 494 |
typedef T result_type;
|
| 495 |
};
|
| 496 |
```
|
| 497 |
|
| 498 |
`operator()` returns `-x`.
|
| 499 |
|
| 500 |
+
``` cpp
|
| 501 |
+
template <> struct plus<void> {
|
| 502 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 503 |
+
-> decltype(std::forward<T>(t) + std::forward<U>(u));
|
| 504 |
+
|
| 505 |
+
typedef unspecified is_transparent;
|
| 506 |
+
};
|
| 507 |
+
```
|
| 508 |
+
|
| 509 |
+
`operator()` returns `std::forward<T>(t) + std::forward<U>(u)`.
|
| 510 |
+
|
| 511 |
+
``` cpp
|
| 512 |
+
template <> struct minus<void> {
|
| 513 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 514 |
+
-> decltype(std::forward<T>(t) - std::forward<U>(u));
|
| 515 |
+
|
| 516 |
+
typedef unspecified is_transparent;
|
| 517 |
+
};
|
| 518 |
+
```
|
| 519 |
+
|
| 520 |
+
`operator()` returns `std::forward<T>(t) - std::forward<U>(u)`.
|
| 521 |
+
|
| 522 |
+
``` cpp
|
| 523 |
+
template <> struct multiplies<void> {
|
| 524 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 525 |
+
-> decltype(std::forward<T>(t) * std::forward<U>(u));
|
| 526 |
+
|
| 527 |
+
typedef unspecified is_transparent;
|
| 528 |
+
};
|
| 529 |
+
```
|
| 530 |
+
|
| 531 |
+
`operator()` returns `std::forward<T>(t) * std::forward<U>(u)`.
|
| 532 |
+
|
| 533 |
+
``` cpp
|
| 534 |
+
template <> struct divides<void> {
|
| 535 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 536 |
+
-> decltype(std::forward<T>(t) / std::forward<U>(u));
|
| 537 |
+
|
| 538 |
+
typedef unspecified is_transparent;
|
| 539 |
+
};
|
| 540 |
+
```
|
| 541 |
+
|
| 542 |
+
`operator()` returns `std::forward<T>(t) / std::forward<U>(u)`.
|
| 543 |
+
|
| 544 |
+
``` cpp
|
| 545 |
+
template <> struct modulus<void> {
|
| 546 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 547 |
+
-> decltype(std::forward<T>(t) % std::forward<U>(u));
|
| 548 |
+
|
| 549 |
+
typedef unspecified is_transparent;
|
| 550 |
+
};
|
| 551 |
+
```
|
| 552 |
+
|
| 553 |
+
`operator()` returns `std::forward<T>(t) % std::forward<U>(u)`.
|
| 554 |
+
|
| 555 |
+
``` cpp
|
| 556 |
+
template <> struct negate<void> {
|
| 557 |
+
template <class T> constexpr auto operator()(T&& t) const
|
| 558 |
+
-> decltype(-std::forward<T>(t));
|
| 559 |
+
|
| 560 |
+
typedef unspecified is_transparent;
|
| 561 |
+
};
|
| 562 |
+
```
|
| 563 |
+
|
| 564 |
+
`operator()` returns `-std::forward<T>(t)`.
|
| 565 |
+
|
| 566 |
### Comparisons <a id="comparisons">[[comparisons]]</a>
|
| 567 |
|
| 568 |
The library provides basic function object classes for all of the
|
| 569 |
comparison operators in the language ([[expr.rel]], [[expr.eq]]).
|
| 570 |
|
| 571 |
``` cpp
|
| 572 |
+
template <class T = void> struct equal_to {
|
| 573 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 574 |
typedef T first_argument_type;
|
| 575 |
typedef T second_argument_type;
|
| 576 |
typedef bool result_type;
|
| 577 |
};
|
| 578 |
```
|
| 579 |
|
| 580 |
`operator()` returns `x == y`.
|
| 581 |
|
| 582 |
``` cpp
|
| 583 |
+
template <class T = void> struct not_equal_to {
|
| 584 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 585 |
typedef T first_argument_type;
|
| 586 |
typedef T second_argument_type;
|
| 587 |
typedef bool result_type;
|
| 588 |
};
|
| 589 |
```
|
| 590 |
|
| 591 |
`operator()` returns `x != y`.
|
| 592 |
|
| 593 |
``` cpp
|
| 594 |
+
template <class T = void> struct greater {
|
| 595 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 596 |
typedef T first_argument_type;
|
| 597 |
typedef T second_argument_type;
|
| 598 |
typedef bool result_type;
|
| 599 |
};
|
| 600 |
```
|
| 601 |
|
| 602 |
`operator()` returns `x > y`.
|
| 603 |
|
| 604 |
``` cpp
|
| 605 |
+
template <class T = void> struct less {
|
| 606 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 607 |
typedef T first_argument_type;
|
| 608 |
typedef T second_argument_type;
|
| 609 |
typedef bool result_type;
|
| 610 |
};
|
| 611 |
```
|
| 612 |
|
| 613 |
`operator()` returns `x < y`.
|
| 614 |
|
| 615 |
``` cpp
|
| 616 |
+
template <class T = void> struct greater_equal {
|
| 617 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 618 |
typedef T first_argument_type;
|
| 619 |
typedef T second_argument_type;
|
| 620 |
typedef bool result_type;
|
| 621 |
};
|
| 622 |
```
|
| 623 |
|
| 624 |
`operator()` returns `x >= y`.
|
| 625 |
|
| 626 |
``` cpp
|
| 627 |
+
template <class T = void> struct less_equal {
|
| 628 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 629 |
typedef T first_argument_type;
|
| 630 |
typedef T second_argument_type;
|
| 631 |
typedef bool result_type;
|
| 632 |
};
|
| 633 |
```
|
| 634 |
|
| 635 |
`operator()` returns `x <= y`.
|
| 636 |
|
| 637 |
+
``` cpp
|
| 638 |
+
template <> struct equal_to<void> {
|
| 639 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 640 |
+
-> decltype(std::forward<T>(t) == std::forward<U>(u));
|
| 641 |
+
|
| 642 |
+
typedef unspecified is_transparent;
|
| 643 |
+
};
|
| 644 |
+
```
|
| 645 |
+
|
| 646 |
+
`operator()` returns `std::forward<T>(t) == std::forward<U>(u)`.
|
| 647 |
+
|
| 648 |
+
``` cpp
|
| 649 |
+
template <> struct not_equal_to<void> {
|
| 650 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 651 |
+
-> decltype(std::forward<T>(t) != std::forward<U>(u));
|
| 652 |
+
|
| 653 |
+
typedef unspecified is_transparent;
|
| 654 |
+
};
|
| 655 |
+
```
|
| 656 |
+
|
| 657 |
+
`operator()` returns `std::forward<T>(t) != std::forward<U>(u)`.
|
| 658 |
+
|
| 659 |
+
``` cpp
|
| 660 |
+
template <> struct greater<void> {
|
| 661 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 662 |
+
-> decltype(std::forward<T>(t) > std::forward<U>(u));
|
| 663 |
+
|
| 664 |
+
typedef unspecified is_transparent;
|
| 665 |
+
};
|
| 666 |
+
```
|
| 667 |
+
|
| 668 |
+
`operator()` returns `std::forward<T>(t) > std::forward<U>(u)`.
|
| 669 |
+
|
| 670 |
+
``` cpp
|
| 671 |
+
template <> struct less<void> {
|
| 672 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 673 |
+
-> decltype(std::forward<T>(t) < std::forward<U>(u));
|
| 674 |
+
|
| 675 |
+
typedef unspecified is_transparent;
|
| 676 |
+
};
|
| 677 |
+
```
|
| 678 |
+
|
| 679 |
+
`operator()` returns `std::forward<T>(t) < std::forward<U>(u)`.
|
| 680 |
+
|
| 681 |
+
``` cpp
|
| 682 |
+
template <> struct greater_equal<void> {
|
| 683 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 684 |
+
-> decltype(std::forward<T>(t) >= std::forward<U>(u));
|
| 685 |
+
|
| 686 |
+
typedef unspecified is_transparent;
|
| 687 |
+
};
|
| 688 |
+
```
|
| 689 |
+
|
| 690 |
+
`operator()` returns `std::forward<T>(t) >= std::forward<U>(u)`.
|
| 691 |
+
|
| 692 |
+
``` cpp
|
| 693 |
+
template <> struct less_equal<void> {
|
| 694 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 695 |
+
-> decltype(std::forward<T>(t) <= std::forward<U>(u));
|
| 696 |
+
|
| 697 |
+
typedef unspecified is_transparent;
|
| 698 |
+
};
|
| 699 |
+
```
|
| 700 |
+
|
| 701 |
+
`operator()` returns `std::forward<T>(t) <= std::forward<U>(u)`.
|
| 702 |
+
|
| 703 |
For templates `greater`, `less`, `greater_equal`, and `less_equal`, the
|
| 704 |
specializations for any pointer type yield a total order, even if the
|
| 705 |
built-in operators `<`, `>`, `<=`, `>=` do not.
|
| 706 |
|
| 707 |
### Logical operations <a id="logical.operations">[[logical.operations]]</a>
|
|
|
|
| 709 |
The library provides basic function object classes for all of the
|
| 710 |
logical operators in the language ([[expr.log.and]], [[expr.log.or]],
|
| 711 |
[[expr.unary.op]]).
|
| 712 |
|
| 713 |
``` cpp
|
| 714 |
+
template <class T = void> struct logical_and {
|
| 715 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 716 |
typedef T first_argument_type;
|
| 717 |
typedef T second_argument_type;
|
| 718 |
typedef bool result_type;
|
| 719 |
};
|
| 720 |
```
|
| 721 |
|
| 722 |
`operator()` returns `x && y`.
|
| 723 |
|
| 724 |
``` cpp
|
| 725 |
+
template <class T = void> struct logical_or {
|
| 726 |
+
constexpr bool operator()(const T& x, const T& y) const;
|
| 727 |
typedef T first_argument_type;
|
| 728 |
typedef T second_argument_type;
|
| 729 |
typedef bool result_type;
|
| 730 |
};
|
| 731 |
```
|
| 732 |
|
| 733 |
`operator()` returns `x || y`.
|
| 734 |
|
| 735 |
``` cpp
|
| 736 |
+
template <class T = void> struct logical_not {
|
| 737 |
+
constexpr bool operator()(const T& x) const;
|
| 738 |
typedef T argument_type;
|
| 739 |
typedef bool result_type;
|
| 740 |
};
|
| 741 |
```
|
| 742 |
|
| 743 |
`operator()` returns `!x`.
|
| 744 |
|
| 745 |
+
``` cpp
|
| 746 |
+
template <> struct logical_and<void> {
|
| 747 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 748 |
+
-> decltype(std::forward<T>(t) && std::forward<U>(u));
|
| 749 |
+
|
| 750 |
+
typedef unspecified is_transparent;
|
| 751 |
+
};
|
| 752 |
+
```
|
| 753 |
+
|
| 754 |
+
`operator()` returns `std::forward<T>(t) && std::forward<U>(u)`.
|
| 755 |
+
|
| 756 |
+
``` cpp
|
| 757 |
+
template <> struct logical_or<void> {
|
| 758 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 759 |
+
-> decltype(std::forward<T>(t) || std::forward<U>(u));
|
| 760 |
+
|
| 761 |
+
typedef unspecified is_transparent;
|
| 762 |
+
};
|
| 763 |
+
```
|
| 764 |
+
|
| 765 |
+
`operator()` returns `std::forward<T>(t) || std::forward<U>(u)`.
|
| 766 |
+
|
| 767 |
+
``` cpp
|
| 768 |
+
template <> struct logical_not<void> {
|
| 769 |
+
template <class T> constexpr auto operator()(T&& t) const
|
| 770 |
+
-> decltype(!std::forward<T>(t));
|
| 771 |
+
|
| 772 |
+
typedef unspecified is_transparent;
|
| 773 |
+
};
|
| 774 |
+
```
|
| 775 |
+
|
| 776 |
+
`operator()` returns `!std::forward<T>(t)`.
|
| 777 |
+
|
| 778 |
### Bitwise operations <a id="bitwise.operations">[[bitwise.operations]]</a>
|
| 779 |
|
| 780 |
The library provides basic function object classes for all of the
|
| 781 |
bitwise operators in the language ([[expr.bit.and]], [[expr.or]],
|
| 782 |
+
[[expr.xor]], [[expr.unary.op]]).
|
| 783 |
|
| 784 |
``` cpp
|
| 785 |
+
template <class T = void> struct bit_and {
|
| 786 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 787 |
typedef T first_argument_type;
|
| 788 |
typedef T second_argument_type;
|
| 789 |
typedef T result_type;
|
| 790 |
};
|
| 791 |
```
|
| 792 |
|
| 793 |
`operator()` returns `x & y`.
|
| 794 |
|
| 795 |
``` cpp
|
| 796 |
+
template <class T = void> struct bit_or {
|
| 797 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 798 |
typedef T first_argument_type;
|
| 799 |
typedef T second_argument_type;
|
| 800 |
typedef T result_type;
|
| 801 |
};
|
| 802 |
```
|
| 803 |
|
| 804 |
`operator()` returns `x | y`.
|
| 805 |
|
| 806 |
``` cpp
|
| 807 |
+
template <class T = void> struct bit_xor {
|
| 808 |
+
constexpr T operator()(const T& x, const T& y) const;
|
| 809 |
typedef T first_argument_type;
|
| 810 |
typedef T second_argument_type;
|
| 811 |
typedef T result_type;
|
| 812 |
};
|
| 813 |
```
|
| 814 |
|
| 815 |
`operator()` returns `x ^ y`.
|
| 816 |
|
| 817 |
+
``` cpp
|
| 818 |
+
template <class T = void> struct bit_not {
|
| 819 |
+
constexpr T operator()(const T& x) const;
|
| 820 |
+
typedef T argument_type;
|
| 821 |
+
typedef T result_type;
|
| 822 |
+
};
|
| 823 |
+
```
|
| 824 |
+
|
| 825 |
+
`operator()` returns `~x`.
|
| 826 |
+
|
| 827 |
+
``` cpp
|
| 828 |
+
template <> struct bit_and<void> {
|
| 829 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 830 |
+
-> decltype(std::forward<T>(t) & std::forward<U>(u));
|
| 831 |
+
|
| 832 |
+
typedef unspecified is_transparent;
|
| 833 |
+
};
|
| 834 |
+
```
|
| 835 |
+
|
| 836 |
+
`operator()` returns `std::forward<T>(t) & std::forward<U>(u)`.
|
| 837 |
+
|
| 838 |
+
``` cpp
|
| 839 |
+
template <> struct bit_or<void> {
|
| 840 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 841 |
+
-> decltype(std::forward<T>(t) | std::forward<U>(u));
|
| 842 |
+
|
| 843 |
+
typedef unspecified is_transparent;
|
| 844 |
+
};
|
| 845 |
+
```
|
| 846 |
+
|
| 847 |
+
`operator()` returns `std::forward<T>(t) | std::forward<U>(u)`.
|
| 848 |
+
|
| 849 |
+
``` cpp
|
| 850 |
+
template <> struct bit_xor<void> {
|
| 851 |
+
template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
| 852 |
+
-> decltype(std::forward<T>(t) ^ std::forward<U>(u));
|
| 853 |
+
|
| 854 |
+
typedef unspecified is_transparent;
|
| 855 |
+
};
|
| 856 |
+
```
|
| 857 |
+
|
| 858 |
+
`operator()` returns `std::forward<T>(t) ^ std::forward<U>(u)`.
|
| 859 |
+
|
| 860 |
+
``` cpp
|
| 861 |
+
template <> struct bit_not<void> {
|
| 862 |
+
template <class T> constexpr auto operator()(T&& t) const
|
| 863 |
+
-> decltype(~std::forward<T>(t));
|
| 864 |
+
|
| 865 |
+
typedef unspecified is_transparent;
|
| 866 |
+
};
|
| 867 |
+
```
|
| 868 |
+
|
| 869 |
+
`operator()` returns `~std::forward<T>(t)`.
|
| 870 |
+
|
| 871 |
### Negators <a id="negators">[[negators]]</a>
|
| 872 |
|
| 873 |
Negators `not1` and `not2` take a unary and a binary predicate,
|
| 874 |
respectively, and return their complements ([[expr.unary.op]]).
|
| 875 |
|
| 876 |
``` cpp
|
| 877 |
template <class Predicate>
|
| 878 |
class unary_negate {
|
| 879 |
public:
|
| 880 |
+
constexpr explicit unary_negate(const Predicate& pred);
|
| 881 |
+
constexpr bool operator()(const typename Predicate::argument_type& x) const;
|
| 882 |
typedef typename Predicate::argument_type argument_type;
|
| 883 |
typedef bool result_type;
|
| 884 |
};
|
| 885 |
```
|
| 886 |
|
| 887 |
`operator()` returns `!pred(x)`.
|
| 888 |
|
| 889 |
``` cpp
|
| 890 |
template <class Predicate>
|
| 891 |
+
constexpr unary_negate<Predicate> not1(const Predicate& pred);
|
| 892 |
```
|
| 893 |
|
| 894 |
*Returns:* `unary_negate<Predicate>(pred)`.
|
| 895 |
|
| 896 |
``` cpp
|
| 897 |
template <class Predicate>
|
| 898 |
class binary_negate {
|
| 899 |
public:
|
| 900 |
+
constexpr explicit binary_negate(const Predicate& pred);
|
| 901 |
+
constexpr bool operator()(const typename Predicate::first_argument_type& x,
|
| 902 |
const typename Predicate::second_argument_type& y) const;
|
| 903 |
typedef typename Predicate::first_argument_type first_argument_type;
|
| 904 |
typedef typename Predicate::second_argument_type second_argument_type;
|
| 905 |
typedef bool result_type;
|
| 906 |
};
|
|
|
|
| 908 |
|
| 909 |
`operator()` returns `!pred(x,y)`.
|
| 910 |
|
| 911 |
``` cpp
|
| 912 |
template <class Predicate>
|
| 913 |
+
constexpr binary_negate<Predicate> not2(const Predicate& pred);
|
| 914 |
```
|
| 915 |
|
| 916 |
*Returns:* `binary_negate<Predicate>(pred)`.
|
| 917 |
|
| 918 |
+
### Function object binders <a id="func.bind">[[func.bind]]</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 919 |
|
| 920 |
This subclause describes a uniform mechanism for binding arguments of
|
| 921 |
callable objects.
|
| 922 |
|
| 923 |
+
#### Class template `is_bind_expression` <a id="func.bind.isbind">[[func.bind.isbind]]</a>
|
| 924 |
|
| 925 |
``` cpp
|
| 926 |
namespace std {
|
| 927 |
+
template<class T> struct is_bind_expression; // see below
|
|
|
|
| 928 |
}
|
| 929 |
```
|
| 930 |
|
| 931 |
`is_bind_expression` can be used to detect function objects generated by
|
| 932 |
+
`bind`. `bind` uses `is_bind_expression` to detect subexpressions.
|
|
|
|
|
|
|
| 933 |
|
| 934 |
+
Instantiations of the `is_bind_expression` template shall meet the
|
| 935 |
+
UnaryTypeTrait requirements ([[meta.rqmts]]). The implementation shall
|
| 936 |
+
provide a definition that has a BaseCharacteristic of `true_type` if `T`
|
| 937 |
+
is a type returned from `bind`, otherwise it shall have a
|
| 938 |
+
BaseCharacteristic of `false_type`. A program may specialize this
|
| 939 |
+
template for a user-defined type `T` to have a BaseCharacteristic of
|
| 940 |
+
`true_type` to indicate that `T` should be treated as a subexpression in
|
| 941 |
+
a `bind` call.
|
| 942 |
+
|
| 943 |
+
#### Class template `is_placeholder` <a id="func.bind.isplace">[[func.bind.isplace]]</a>
|
| 944 |
+
|
| 945 |
+
``` cpp
|
| 946 |
+
namespace std {
|
| 947 |
+
template<class T> struct is_placeholder; // see below
|
| 948 |
+
}
|
| 949 |
+
```
|
| 950 |
|
| 951 |
`is_placeholder` can be used to detect the standard placeholders `_1`,
|
| 952 |
`_2`, and so on. `bind` uses `is_placeholder` to detect placeholders.
|
|
|
|
| 953 |
|
| 954 |
+
Instantiations of the `is_placeholder` template shall meet the
|
| 955 |
+
UnaryTypeTrait requirements ([[meta.rqmts]]). The implementation shall
|
| 956 |
+
provide a definition that has the BaseCharacteristic of
|
| 957 |
+
`integral_constant<int, J>` if `T` is the type of
|
| 958 |
+
`std::placeholders::_J`, otherwise it shall have a BaseCharacteristic of
|
| 959 |
+
`integral_constant<int, 0>`. A program may specialize this template for
|
| 960 |
+
a user-defined type `T` to have a BaseCharacteristic of
|
| 961 |
+
`integral_constant<int, N>` with `N > 0` to indicate that `T` should be
|
| 962 |
+
treated as a placeholder type.
|
| 963 |
|
| 964 |
+
#### Function template `bind` <a id="func.bind.bind">[[func.bind.bind]]</a>
|
| 965 |
|
| 966 |
In the text that follows, the following names have the following
|
| 967 |
meanings:
|
| 968 |
|
| 969 |
+
- `FD` is the type `decay_t<F>`,
|
| 970 |
- `fd` is an lvalue of type `FD` constructed from `std::forward<F>(f)`,
|
| 971 |
+
- `Ti` is the iᵗʰ type in the template parameter pack `BoundArgs`,
|
| 972 |
+
- `TiD` is the type `decay_t<Ti>`,
|
| 973 |
- `ti` is the iᵗʰ argument in the function parameter pack `bound_args`,
|
| 974 |
- `tid` is an lvalue of type `TiD` constructed from
|
| 975 |
`std::forward<Ti>(ti)`,
|
| 976 |
- `Uj` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
|
| 977 |
the forwarding call wrapper, and
|
|
|
|
| 988 |
expression for some values *w1, w2, ..., wN*, where
|
| 989 |
`N == sizeof...(bound_args)`.
|
| 990 |
|
| 991 |
*Returns:* A forwarding call wrapper `g` with a weak result
|
| 992 |
type ([[func.require]]). The effect of `g(u1, u2, ..., uM)` shall be
|
| 993 |
+
*`INVOKE`*`(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), result_of_t<FD `*`cv`*` & (V1, V2, ..., VN)>)`,
|
| 994 |
where *`cv`* represents the *cv*-qualifiers of `g` and the values and
|
| 995 |
types of the bound arguments `v1, v2, ..., vN` are determined as
|
| 996 |
specified below. The copy constructor and move constructor of the
|
| 997 |
forwarding call wrapper shall throw an exception if and only if the
|
| 998 |
corresponding constructor of `FD` or of any of the types `TiD` throws an
|
|
|
|
| 1017 |
*`INVOKE`*`(fd, w1, w2, ..., wN)` shall be a valid expression for some
|
| 1018 |
values *w1, w2, ..., wN*, where `N == sizeof...(bound_args)`.
|
| 1019 |
|
| 1020 |
*Returns:* A forwarding call wrapper `g` with a nested type
|
| 1021 |
`result_type` defined as a synonym for `R`. The effect of
|
| 1022 |
+
`g(u1, u2, ..., uM)` shall be
|
| 1023 |
+
*`INVOKE`*`(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), R)`,
|
| 1024 |
where the values and types of the bound arguments `v1, v2, ..., vN` are
|
| 1025 |
determined as specified below. The copy constructor and move constructor
|
| 1026 |
of the forwarding call wrapper shall throw an exception if and only if
|
| 1027 |
the corresponding constructor of `FD` or of any of the types `TiD`
|
| 1028 |
throws an exception.
|
|
|
|
| 1043 |
|
| 1044 |
- if `TiD` is `reference_wrapper<T>`, the argument is `tid.get()` and
|
| 1045 |
its type `Vi` is `T&`;
|
| 1046 |
- if the value of `is_bind_expression<TiD>::value` is `true`, the
|
| 1047 |
argument is `tid(std::forward<Uj>({}uj)...)` and its type `Vi` is
|
| 1048 |
+
`result_of_t<TiD cv & (Uj&&...)>&&`;
|
| 1049 |
- if the value `j` of `is_placeholder<TiD>::value` is not zero, the
|
| 1050 |
argument is `std::forward<Uj>(uj)` and its type `Vi` is `Uj&&`;
|
| 1051 |
- otherwise, the value is `tid` and its type `Vi` is `TiD cv &`.
|
| 1052 |
|
| 1053 |
+
#### Placeholders <a id="func.bind.place">[[func.bind.place]]</a>
|
| 1054 |
|
| 1055 |
``` cpp
|
| 1056 |
namespace std {
|
| 1057 |
namespace placeholders {
|
| 1058 |
// M is the implementation-defined number of placeholders
|
|
|
|
| 1073 |
placeholders’ copy assignment operators shall not throw exceptions.
|
| 1074 |
|
| 1075 |
### Function template `mem_fn` <a id="func.memfn">[[func.memfn]]</a>
|
| 1076 |
|
| 1077 |
``` cpp
|
| 1078 |
+
template<class R, class T> unspecified mem_fn(R T::* pm);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1079 |
```
|
| 1080 |
|
| 1081 |
*Returns:* A simple call wrapper ([[func.def]]) `fn` such that the
|
| 1082 |
expression `fn(t, a2, ..., aN)` is equivalent to
|
| 1083 |
*`INVOKE`*`(pm, t, a2, ..., aN)` ([[func.require]]). `fn` shall have a
|
|
|
|
| 1135 |
|
| 1136 |
template<class R, class... ArgTypes>
|
| 1137 |
class function<R(ArgTypes...)> {
|
| 1138 |
public:
|
| 1139 |
typedef R result_type;
|
| 1140 |
+
typedef T1 argument_type; // only if sizeof...(ArgTypes) == 1 and
|
| 1141 |
// the type in ArgTypes is T1
|
| 1142 |
+
typedef T1 first_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 1143 |
// ArgTypes contains T1 and T2
|
| 1144 |
+
typedef T2 second_argument_type; // only if sizeof...(ArgTypes) == 2 and
|
| 1145 |
// ArgTypes contains T1 and T2
|
| 1146 |
|
| 1147 |
// [func.wrap.func.con], construct/copy/destroy:
|
| 1148 |
function() noexcept;
|
| 1149 |
function(nullptr_t) noexcept;
|
|
|
|
| 1177 |
// [func.wrap.func.inv], function invocation:
|
| 1178 |
R operator()(ArgTypes...) const;
|
| 1179 |
|
| 1180 |
// [func.wrap.func.targ], function target access:
|
| 1181 |
const std::type_info& target_type() const noexcept;
|
| 1182 |
+
template<class T> T* target() noexcept;
|
| 1183 |
+
template<class T> const T* target() const noexcept;
|
| 1184 |
|
| 1185 |
};
|
| 1186 |
|
| 1187 |
// [func.wrap.func.nullptr], Null pointer comparisons:
|
| 1188 |
template <class R, class... ArgTypes>
|
|
|
|
| 1271 |
``` cpp
|
| 1272 |
template<class F> function(F f);
|
| 1273 |
template <class F, class A> function(allocator_arg_t, const A& a, F f);
|
| 1274 |
```
|
| 1275 |
|
| 1276 |
+
*Requires:* `F` shall be `CopyConstructible`.
|
| 1277 |
+
|
| 1278 |
+
*Remarks:* These constructors shall not participate in overload
|
| 1279 |
+
resolution unless `f` is Callable ([[func.wrap.func]]) for argument
|
| 1280 |
+
types `ArgTypes...` and return type `R`.
|
| 1281 |
|
| 1282 |
*Postconditions:* `!*this` if any of the following hold:
|
| 1283 |
|
| 1284 |
+
- `f` is a null function pointer value.
|
| 1285 |
+
- `f` is a null member pointer value.
|
| 1286 |
+
- `F` is an instance of the `function` class template, and `!f`.
|
| 1287 |
|
| 1288 |
Otherwise, `*this` targets a copy of `f` initialized with
|
| 1289 |
`std::move(f)`. Implementations are encouraged to avoid the use of
|
| 1290 |
dynamically allocated memory for small callable objects, for example,
|
| 1291 |
where `f`’s target is an object holding only a pointer or reference to
|
|
|
|
| 1313 |
|
| 1314 |
``` cpp
|
| 1315 |
function& operator=(nullptr_t);
|
| 1316 |
```
|
| 1317 |
|
| 1318 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 1319 |
|
| 1320 |
*Postconditions:* `!(*this)`.
|
| 1321 |
|
| 1322 |
*Returns:* `*this`
|
| 1323 |
|
|
|
|
| 1327 |
|
| 1328 |
*Effects:* `function(std::forward<F>(f)).swap(*this);`
|
| 1329 |
|
| 1330 |
*Returns:* `*this`
|
| 1331 |
|
| 1332 |
+
*Remarks:* This assignment operator shall not participate in overload
|
| 1333 |
+
resolution unless `declval<typename decay<F>::type&>()` is
|
| 1334 |
+
Callable ([[func.wrap.func]]) for argument types `ArgTypes...` and
|
| 1335 |
+
return type `R`.
|
| 1336 |
+
|
| 1337 |
``` cpp
|
| 1338 |
template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
| 1339 |
```
|
| 1340 |
|
| 1341 |
*Effects:* `function(f).swap(*this);`
|
|
|
|
| 1344 |
|
| 1345 |
``` cpp
|
| 1346 |
~function();
|
| 1347 |
```
|
| 1348 |
|
| 1349 |
+
*Effects:* If `*this != nullptr`, destroys the target of `this`.
|
| 1350 |
|
| 1351 |
##### `function` modifiers <a id="func.wrap.func.mod">[[func.wrap.func.mod]]</a>
|
| 1352 |
|
| 1353 |
``` cpp
|
| 1354 |
void swap(function& other) noexcept;
|
|
|
|
| 1395 |
|
| 1396 |
*Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
|
| 1397 |
`typeid(void)`.
|
| 1398 |
|
| 1399 |
``` cpp
|
| 1400 |
+
template<class T> T* target() noexcept;
|
| 1401 |
+
template<class T> const T* target() const noexcept;
|
| 1402 |
```
|
| 1403 |
|
| 1404 |
*Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
|
| 1405 |
for parameter types `ArgTypes` and return type `R`.
|
| 1406 |
|
| 1407 |
+
*Returns:* If `target_type() == typeid(T)` a pointer to the stored
|
| 1408 |
function target; otherwise a null pointer.
|
| 1409 |
|
| 1410 |
##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
|
| 1411 |
|
| 1412 |
``` cpp
|
|
|
|
| 1439 |
### Class template `hash` <a id="unord.hash">[[unord.hash]]</a>
|
| 1440 |
|
| 1441 |
The unordered associative containers defined in [[unord]] use
|
| 1442 |
specializations of the class template `hash` as the default hash
|
| 1443 |
function. For all object types `Key` for which there exists a
|
| 1444 |
+
specialization `hash<Key>`, and for all enumeration types (
|
| 1445 |
+
[[dcl.enum]]) `Key`, the instantiation `hash<Key>` shall:
|
| 1446 |
|
| 1447 |
- satisfy the `Hash` requirements ([[hash.requirements]]), with `Key`
|
| 1448 |
as the function call argument type, the `DefaultConstructible`
|
| 1449 |
requirements (Table [[defaultconstructible]]), the `CopyAssignable`
|
| 1450 |
requirements (Table [[copyassignable]]),
|
|
|
|
| 1479 |
template <> struct hash<double>;
|
| 1480 |
template <> struct hash<long double>;
|
| 1481 |
template <class T> struct hash<T*>;
|
| 1482 |
```
|
| 1483 |
|
| 1484 |
+
The template specializations shall meet the requirements of class
|
| 1485 |
+
template `hash` ([[unord.hash]]).
|
| 1486 |
|