tmp/tmp5b0nog57/{from.md → to.md}
RENAMED
|
@@ -1,48 +1,65 @@
|
|
| 1 |
### Calling a function with a `tuple` of arguments <a id="tuple.apply">[[tuple.apply]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
-
template<class F,
|
| 5 |
-
constexpr decltype(auto) apply(F&& f, Tuple&& t);
|
| 6 |
```
|
| 7 |
|
| 8 |
*Effects:* Given the exposition-only function:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
-
|
|
|
|
| 12 |
constexpr decltype(auto) apply-impl(F&& f, Tuple&& t, index_sequence<I...>) {
|
| 13 |
// exposition only
|
| 14 |
-
|
|
|
|
| 15 |
}
|
| 16 |
```
|
| 17 |
|
| 18 |
Equivalent to:
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
return apply-impl(std::forward<F>(f), std::forward<Tuple>(t),
|
| 22 |
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
|
| 23 |
```
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
``` cpp
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
constexpr T make_from_tuple(Tuple&& t);
|
| 28 |
```
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
*Effects:* Given the exposition-only function:
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
constexpr T make-from-tuple-impl(Tuple&& t, index_sequence<I...>) { // exposition only
|
| 35 |
return T(get<I>(std::forward<Tuple>(t))...);
|
| 36 |
}
|
|
|
|
| 37 |
```
|
| 38 |
|
| 39 |
Equivalent to:
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
return make-from-tuple-impl<T>(
|
| 43 |
-
forward<Tuple>(t),
|
| 44 |
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
|
| 45 |
```
|
| 46 |
|
| 47 |
[*Note 1*: The type of `T` must be supplied as an explicit template
|
| 48 |
parameter, as it cannot be deduced from the argument
|
|
|
|
| 1 |
### Calling a function with a `tuple` of arguments <a id="tuple.apply">[[tuple.apply]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
+
template<class F, tuple-like Tuple>
|
| 5 |
+
constexpr decltype(auto) apply(F&& f, Tuple&& t) noexcept(see below);
|
| 6 |
```
|
| 7 |
|
| 8 |
*Effects:* Given the exposition-only function:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
+
namespace std {
|
| 12 |
+
template<class F, tuple-like Tuple, size_t... I>
|
| 13 |
constexpr decltype(auto) apply-impl(F&& f, Tuple&& t, index_sequence<I...>) {
|
| 14 |
// exposition only
|
| 15 |
+
return INVOKE(std::forward<F>(f), get<I>(std::forward<Tuple>(t))...); // see [func.require]
|
| 16 |
+
}
|
| 17 |
}
|
| 18 |
```
|
| 19 |
|
| 20 |
Equivalent to:
|
| 21 |
|
| 22 |
``` cpp
|
| 23 |
return apply-impl(std::forward<F>(f), std::forward<Tuple>(t),
|
| 24 |
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
|
| 25 |
```
|
| 26 |
|
| 27 |
+
*Remarks:* Let `I` be the pack
|
| 28 |
+
`0, 1, ..., (tuple_size_v<remove_reference_t<Tuple>> - 1)`. The
|
| 29 |
+
exception specification is equivalent to:
|
| 30 |
+
|
| 31 |
``` cpp
|
| 32 |
+
noexcept(invoke(std::forward<F>(f), get<I>(std::forward<Tuple>(t))...))
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
``` cpp
|
| 36 |
+
template<class T, tuple-like Tuple>
|
| 37 |
constexpr T make_from_tuple(Tuple&& t);
|
| 38 |
```
|
| 39 |
|
| 40 |
+
*Mandates:* If `tuple_size_v<remove_reference_t<Tuple>>` is 1, then
|
| 41 |
+
`reference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))>`
|
| 42 |
+
is `false`.
|
| 43 |
+
|
| 44 |
*Effects:* Given the exposition-only function:
|
| 45 |
|
| 46 |
``` cpp
|
| 47 |
+
namespace std {
|
| 48 |
+
template<class T, tuple-like Tuple, size_t... I>
|
| 49 |
+
requires is_constructible_v<T, decltype(get<I>(declval<Tuple>()))...>
|
| 50 |
constexpr T make-from-tuple-impl(Tuple&& t, index_sequence<I...>) { // exposition only
|
| 51 |
return T(get<I>(std::forward<Tuple>(t))...);
|
| 52 |
}
|
| 53 |
+
}
|
| 54 |
```
|
| 55 |
|
| 56 |
Equivalent to:
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
return make-from-tuple-impl<T>(
|
| 60 |
+
std::forward<Tuple>(t),
|
| 61 |
make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
|
| 62 |
```
|
| 63 |
|
| 64 |
[*Note 1*: The type of `T` must be supplied as an explicit template
|
| 65 |
parameter, as it cannot be deduced from the argument
|