From Jason Turner

[tuple.apply]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwmvwes2y/{from.md → to.md} +49 -0
tmp/tmpwmvwes2y/{from.md → to.md} RENAMED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Calling a function with a `tuple` of arguments <a id="tuple.apply">[[tuple.apply]]</a>
2
+
3
+ ``` cpp
4
+ template <class F, class Tuple>
5
+ constexpr decltype(auto) apply(F&& f, Tuple&& t);
6
+ ```
7
+
8
+ *Effects:* Given the exposition-only function:
9
+
10
+ ``` cpp
11
+ template <class F, class Tuple, size_t... I>
12
+ constexpr decltype(auto)
13
+ apply_impl(F&& f, Tuple&& t, index_sequence<I...>) { // exposition only
14
+ return INVOKE(std::forward<F>(f), std::get<I>(std::forward<Tuple>(t))...);
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<decay_t<Tuple>>>{});
23
+ ```
24
+
25
+ ``` cpp
26
+ template <class T, class Tuple>
27
+ constexpr T make_from_tuple(Tuple&& t);
28
+ ```
29
+
30
+ *Effects:* Given the exposition-only function:
31
+
32
+ ``` cpp
33
+ template <class T, class Tuple, size_t... I>
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>(forward<Tuple>(t),
43
+ make_index_sequence<tuple_size_v<decay_t<Tuple>>>{});
44
+ ```
45
+
46
+ [*Note 1*: The type of `T` must be supplied as an explicit template
47
+ parameter, as it cannot be deduced from the argument
48
+ list. — *end note*]
49
+