tmp/tmpq_gn4yox/{from.md → to.md}
RENAMED
|
@@ -1,46 +1,77 @@
|
|
| 1 |
### Requirements <a id="func.require">[[func.require]]</a>
|
| 2 |
|
| 3 |
-
Define `INVOKE(f,
|
| 4 |
|
| 5 |
-
- `(
|
| 6 |
-
class `T` and `is_base_of_v<T,
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
| 16 |
`reference_wrapper`;
|
| 17 |
-
- `(*
|
| 18 |
-
class `T` and `
|
| 19 |
-
- `f(
|
| 20 |
|
| 21 |
-
Define `INVOKE<R>(f,
|
| 22 |
-
`static_cast<void>(INVOKE(f,
|
| 23 |
-
otherwise `INVOKE(f,
|
| 24 |
|
| 25 |
-
Every call wrapper
|
| 26 |
-
*
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
forwarding call wrapper that is `CopyConstructible` and `CopyAssignable`
|
| 32 |
-
and whose copy constructor, move constructor, and assignment operator do
|
| 33 |
-
not throw exceptions.
|
| 34 |
|
| 35 |
[*Note 1*:
|
| 36 |
|
| 37 |
-
In a typical implementation forwarding call wrappers have an
|
| 38 |
-
function call operator of the form
|
| 39 |
|
| 40 |
``` cpp
|
| 41 |
template<class... UnBoundArgs>
|
| 42 |
-
R operator()(UnBoundArgs&&... unbound_args) cv-qual;
|
| 43 |
```
|
| 44 |
|
| 45 |
— *end note*]
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
### Requirements <a id="func.require">[[func.require]]</a>
|
| 2 |
|
| 3 |
+
Define `INVOKE(f, t₁, t₂, …, t_N)` as follows:
|
| 4 |
|
| 5 |
+
- `(t₁.*f)(t₂, …, t_N)` when `f` is a pointer to a member function of a
|
| 6 |
+
class `T` and `is_base_of_v<T, remove_reference_t<decltype(t₁)>>` is
|
| 7 |
+
`true`;
|
| 8 |
+
- `(t₁.get().*f)(t₂, …, t_N)` when `f` is a pointer to a member function
|
| 9 |
+
of a class `T` and `remove_cvref_t<decltype(t₁)>` is a specialization
|
| 10 |
+
of `reference_wrapper`;
|
| 11 |
+
- `((*t₁).*f)(t₂, …, t_N)` when `f` is a pointer to a member function of
|
| 12 |
+
a class `T` and `t₁` does not satisfy the previous two items;
|
| 13 |
+
- `t₁.*f` when `N == 1` and `f` is a pointer to data member of a class
|
| 14 |
+
`T` and `is_base_of_v<T, remove_reference_t<decltype(t₁)>>` is `true`;
|
| 15 |
+
- `t₁.get().*f` when `N == 1` and `f` is a pointer to data member of a
|
| 16 |
+
class `T` and `remove_cvref_t<decltype(t₁)>` is a specialization of
|
| 17 |
`reference_wrapper`;
|
| 18 |
+
- `(*t₁).*f` when `N == 1` and `f` is a pointer to data member of a
|
| 19 |
+
class `T` and `t₁` does not satisfy the previous two items;
|
| 20 |
+
- `f(t₁, t₂, …, t_N)` in all other cases.
|
| 21 |
|
| 22 |
+
Define `INVOKE<R>(f, t₁, t₂, …, t_N)` as
|
| 23 |
+
`static_cast<void>(INVOKE(f, t₁, t₂, …, t_N))` if `R` is cv `void`,
|
| 24 |
+
otherwise `INVOKE(f, t₁, t₂, …, t_N)` implicitly converted to `R`.
|
| 25 |
|
| 26 |
+
Every call wrapper [[func.def]] meets the *Cpp17MoveConstructible* and
|
| 27 |
+
*Cpp17Destructible* requirements. An *argument forwarding call wrapper*
|
| 28 |
+
is a call wrapper that can be called with an arbitrary argument list and
|
| 29 |
+
delivers the arguments to the wrapped callable object as references.
|
| 30 |
+
This forwarding step delivers rvalue arguments as rvalue references and
|
| 31 |
+
lvalue arguments as lvalue references.
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
[*Note 1*:
|
| 34 |
|
| 35 |
+
In a typical implementation, argument forwarding call wrappers have an
|
| 36 |
+
overloaded function call operator of the form
|
| 37 |
|
| 38 |
``` cpp
|
| 39 |
template<class... UnBoundArgs>
|
| 40 |
+
constexpr R operator()(UnBoundArgs&&... unbound_args) cv-qual;
|
| 41 |
```
|
| 42 |
|
| 43 |
— *end note*]
|
| 44 |
|
| 45 |
+
A *perfect forwarding call wrapper* is an argument forwarding call
|
| 46 |
+
wrapper that forwards its state entities to the underlying call
|
| 47 |
+
expression. This forwarding step delivers a state entity of type `T` as
|
| 48 |
+
cv `T&` when the call is performed on an lvalue of the call wrapper type
|
| 49 |
+
and as cv `T&&` otherwise, where cv represents the cv-qualifiers of the
|
| 50 |
+
call wrapper and where cv shall be neither `volatile` nor
|
| 51 |
+
`const volatile`.
|
| 52 |
+
|
| 53 |
+
A *call pattern* defines the semantics of invoking a perfect forwarding
|
| 54 |
+
call wrapper. A postfix call performed on a perfect forwarding call
|
| 55 |
+
wrapper is expression-equivalent [[defns.expression-equivalent]] to an
|
| 56 |
+
expression `e` determined from its call pattern `cp` by replacing all
|
| 57 |
+
occurrences of the arguments of the call wrapper and its state entities
|
| 58 |
+
with references as described in the corresponding forwarding steps.
|
| 59 |
+
|
| 60 |
+
A *simple call wrapper* is a perfect forwarding call wrapper that meets
|
| 61 |
+
the *Cpp17CopyConstructible* and *Cpp17CopyAssignable* requirements and
|
| 62 |
+
whose copy constructor, move constructor, and assignment operators are
|
| 63 |
+
constexpr functions that do not throw exceptions.
|
| 64 |
+
|
| 65 |
+
The copy/move constructor of an argument forwarding call wrapper has the
|
| 66 |
+
same apparent semantics as if memberwise copy/move of its state entities
|
| 67 |
+
were performed [[class.copy.ctor]].
|
| 68 |
+
|
| 69 |
+
[*Note 2*: This implies that each of the copy/move constructors has the
|
| 70 |
+
same exception-specification as the corresponding implicit definition
|
| 71 |
+
and is declared as `constexpr` if the corresponding implicit definition
|
| 72 |
+
would be considered to be constexpr. — *end note*]
|
| 73 |
+
|
| 74 |
+
Argument forwarding call wrappers returned by a given standard library
|
| 75 |
+
function template have the same type if the types of their corresponding
|
| 76 |
+
state entities are the same.
|
| 77 |
+
|