tmp/tmpziesah81/{from.md → to.md}
RENAMED
|
@@ -1,94 +1,103 @@
|
|
| 1 |
#### Tuple creation functions <a id="tuple.creation">[[tuple.creation]]</a>
|
| 2 |
|
| 3 |
-
In the function descriptions that follow,
|
| 4 |
-
`
|
| 5 |
-
|
| 6 |
-
`sizeof...(UTypes)`) in order and Uⱼ be the jᵗʰ type in a template
|
| 7 |
-
parameter pack named `UTypes`, where indexing is zero-based.
|
| 8 |
|
| 9 |
``` cpp
|
| 10 |
-
template<class...
|
| 11 |
-
constexpr tuple<VTypes...> make_tuple(
|
| 12 |
```
|
| 13 |
|
| 14 |
-
Let Uᵢ be `decay_t<
|
| 15 |
-
`
|
| 16 |
-
Uᵢ
|
|
|
|
| 17 |
|
| 18 |
-
*Returns:* `tuple<VTypes...>(std::forward<
|
|
|
|
|
|
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
int i; float j;
|
| 22 |
make_tuple(1, ref(i), cref(j))
|
| 23 |
```
|
| 24 |
|
| 25 |
-
creates a tuple of type
|
| 26 |
|
| 27 |
-
|
| 28 |
-
tuple<int, int&, const float&>
|
| 29 |
-
```
|
| 30 |
|
| 31 |
``` cpp
|
| 32 |
-
template<class...
|
| 33 |
-
constexpr tuple<
|
| 34 |
```
|
| 35 |
|
| 36 |
*Effects:* Constructs a tuple of references to the arguments in `t`
|
| 37 |
suitable for forwarding as arguments to a function. Because the result
|
| 38 |
may contain references to temporary variables, a program shall ensure
|
| 39 |
that the return value of this function does not outlive any of its
|
| 40 |
-
arguments
|
| 41 |
named variable).
|
| 42 |
|
| 43 |
-
*Returns:* `tuple<
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
-
template<class...
|
| 47 |
-
constexpr tuple<
|
| 48 |
```
|
| 49 |
|
| 50 |
-
*Returns:* `tuple<
|
| 51 |
`ignore`, assigning any value to the corresponding tuple element has no
|
| 52 |
effect.
|
| 53 |
|
|
|
|
|
|
|
| 54 |
`tie` functions allow one to create tuples that unpack tuples into
|
| 55 |
variables. `ignore` can be used for elements that are not needed:
|
| 56 |
|
| 57 |
``` cpp
|
| 58 |
int i; std::string s;
|
| 59 |
tie(i, ignore, s) = make_tuple(42, 3.14, "C++");
|
| 60 |
// i == 42, s == "C++"
|
| 61 |
```
|
| 62 |
|
|
|
|
|
|
|
| 63 |
``` cpp
|
| 64 |
template <class... Tuples>
|
| 65 |
constexpr tuple<CTypes...> tuple_cat(Tuples&&... tpls);
|
| 66 |
```
|
| 67 |
|
| 68 |
-
In the following paragraphs, let Tᵢ be the iᵗʰ type in `Tuples`, Uᵢ
|
| 69 |
-
`remove_reference_t<
|
| 70 |
-
parameter pack `tpls`, where all indexing is zero-based.
|
| 71 |
|
| 72 |
-
*Requires:* For all i, Uᵢ shall be the type cvᵢ `tuple<`Argsᵢ...
|
| 73 |
-
where cvᵢ is the (possibly empty) iᵗʰ cv-qualifier-seq and Argsᵢ is
|
| 74 |
-
parameter pack representing the element types in Uᵢ. Let
|
| 75 |
-
k
|
| 76 |
-
satisfied:
|
| 77 |
-
`is_constructible<`Aᵢₖ`, `cvᵢ` `Aᵢₖ`&>::value == true`, otherwise
|
| 78 |
-
`is_constructible<`Aᵢₖ`, `cvᵢ Aᵢₖ`&&>::value == true`.
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
to the
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
*Returns:* A `tuple` object constructed by initializing the kᵢᵗʰ type
|
| 87 |
-
element
|
| 88 |
-
`get<`kᵢ`>(std::forward<`Tᵢ`>(`tpᵢ`))` for each valid kᵢ and each group
|
| 89 |
-
eᵢ in order.
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
|
|
|
| 1 |
#### Tuple creation functions <a id="tuple.creation">[[tuple.creation]]</a>
|
| 2 |
|
| 3 |
+
In the function descriptions that follow, the members of a parameter
|
| 4 |
+
pack `XTypes` are denoted by `X`ᵢ for i in \[`0`,
|
| 5 |
+
`sizeof...(`*X*`Types)`) in order, where indexing is zero-based.
|
|
|
|
|
|
|
| 6 |
|
| 7 |
``` cpp
|
| 8 |
+
template<class... TTypes>
|
| 9 |
+
constexpr tuple<VTypes...> make_tuple(TTypes&&... t);
|
| 10 |
```
|
| 11 |
|
| 12 |
+
The pack `VTypes` is defined as follows. Let `U`ᵢ be `decay_t<T`ᵢ`>` for
|
| 13 |
+
each `T`ᵢ in `TTypes`. If `U`ᵢ is a specialization of
|
| 14 |
+
`reference_wrapper`, then `V`ᵢ in `VTypes` is `U`ᵢ`::type&`, otherwise
|
| 15 |
+
`V`ᵢ is `U`ᵢ.
|
| 16 |
|
| 17 |
+
*Returns:* `tuple<VTypes...>(std::forward<TTypes>(t)...)`.
|
| 18 |
+
|
| 19 |
+
[*Example 1*:
|
| 20 |
|
| 21 |
``` cpp
|
| 22 |
int i; float j;
|
| 23 |
make_tuple(1, ref(i), cref(j))
|
| 24 |
```
|
| 25 |
|
| 26 |
+
creates a tuple of type `tuple<int, int&, const float&>`.
|
| 27 |
|
| 28 |
+
— *end example*]
|
|
|
|
|
|
|
| 29 |
|
| 30 |
``` cpp
|
| 31 |
+
template<class... TTypes>
|
| 32 |
+
constexpr tuple<TTypes&&...> forward_as_tuple(TTypes&&... t) noexcept;
|
| 33 |
```
|
| 34 |
|
| 35 |
*Effects:* Constructs a tuple of references to the arguments in `t`
|
| 36 |
suitable for forwarding as arguments to a function. Because the result
|
| 37 |
may contain references to temporary variables, a program shall ensure
|
| 38 |
that the return value of this function does not outlive any of its
|
| 39 |
+
arguments (e.g., the program should typically not store the result in a
|
| 40 |
named variable).
|
| 41 |
|
| 42 |
+
*Returns:* `tuple<TTypes&&...>(std::forward<TTypes>(t)...)`.
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
+
template<class... TTypes>
|
| 46 |
+
constexpr tuple<TTypes&...> tie(TTypes&... t) noexcept;
|
| 47 |
```
|
| 48 |
|
| 49 |
+
*Returns:* `tuple<TTypes&...>(t...)`. When an argument in `t` is
|
| 50 |
`ignore`, assigning any value to the corresponding tuple element has no
|
| 51 |
effect.
|
| 52 |
|
| 53 |
+
[*Example 2*:
|
| 54 |
+
|
| 55 |
`tie` functions allow one to create tuples that unpack tuples into
|
| 56 |
variables. `ignore` can be used for elements that are not needed:
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
int i; std::string s;
|
| 60 |
tie(i, ignore, s) = make_tuple(42, 3.14, "C++");
|
| 61 |
// i == 42, s == "C++"
|
| 62 |
```
|
| 63 |
|
| 64 |
+
— *end example*]
|
| 65 |
+
|
| 66 |
``` cpp
|
| 67 |
template <class... Tuples>
|
| 68 |
constexpr tuple<CTypes...> tuple_cat(Tuples&&... tpls);
|
| 69 |
```
|
| 70 |
|
| 71 |
+
In the following paragraphs, let `Tᵢ` be the iᵗʰ type in `Tuples`, `Uᵢ`
|
| 72 |
+
be `remove_reference_t<T`ᵢ`>`, and `tpᵢ` be the iᵗʰ parameter in the
|
| 73 |
+
function parameter pack `tpls`, where all indexing is zero-based.
|
| 74 |
|
| 75 |
+
*Requires:* For all i, `Uᵢ` shall be the type cvᵢ `tuple<``Argsᵢ``...>`,
|
| 76 |
+
where cvᵢ is the (possibly empty) iᵗʰ *cv-qualifier-seq* and `Argsᵢ` is
|
| 77 |
+
the parameter pack representing the element types in `Uᵢ`. Let `A_ik` be
|
| 78 |
+
the kᵗʰ type in `Argsᵢ`. For all `A_ik` the following requirements shall
|
| 79 |
+
be satisfied:
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
- If `Tᵢ` is deduced as an lvalue reference type, then
|
| 82 |
+
`is_constructible_v<``A_ik``, `cvᵢ `A_ik``&> == true`, otherwise
|
| 83 |
+
- `is_constructible_v<``A_ik``, `cvᵢ `A_ik``&&> == true`.
|
| 84 |
+
|
| 85 |
+
*Remarks:* The types in `CTypes` shall be equal to the ordered sequence
|
| 86 |
+
of the extended types `Args₀``..., ``Args₁``..., `…`, ``Args_n-1``...`,
|
| 87 |
+
where n is equal to `sizeof...(Tuples)`. Let `eᵢ``...` be the iᵗʰ
|
| 88 |
+
ordered sequence of tuple elements of the resulting `tuple` object
|
| 89 |
+
corresponding to the type sequence `Argsᵢ`.
|
| 90 |
|
| 91 |
*Returns:* A `tuple` object constructed by initializing the kᵢᵗʰ type
|
| 92 |
+
element `e_ik` in `eᵢ``...` with
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
``` cpp
|
| 95 |
+
get<kᵢ>(std::forward<$T_i$>($tp_i$))
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
for each valid kᵢ and each group `eᵢ` in order.
|
| 99 |
+
|
| 100 |
+
[*Note 1*: An implementation may support additional types in the
|
| 101 |
+
parameter pack `Tuples` that support the `tuple`-like protocol, such as
|
| 102 |
+
`pair` and `array`. — *end note*]
|
| 103 |
|