tmp/tmp2iwj8me_/{from.md → to.md}
RENAMED
|
@@ -1,21 +1,21 @@
|
|
| 1 |
#### Element access <a id="tuple.elem">[[tuple.elem]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template <size_t I, class... Types>
|
| 5 |
-
|
| 6 |
```
|
| 7 |
|
| 8 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 9 |
out of bounds.
|
| 10 |
|
| 11 |
*Returns:* A reference to the `I`th element of `t`, where indexing is
|
| 12 |
zero-based.
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
-
template <size_t I, class...
|
| 16 |
-
|
| 17 |
```
|
| 18 |
|
| 19 |
*Effects:* Equivalent to
|
| 20 |
`return std::forward<typename tuple_element<I, tuple<Types...> >`
|
| 21 |
`::type&&>(get<I>(t));`
|
|
@@ -24,11 +24,11 @@ template <size_t I, class... types>
|
|
| 24 |
is `X&`, not `X&&`. However, if the element type is a non-reference type
|
| 25 |
`T`, the return type is `T&&`.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
template <size_t I, class... Types>
|
| 29 |
-
|
| 30 |
```
|
| 31 |
|
| 32 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 33 |
out of bounds.
|
| 34 |
|
|
@@ -39,9 +39,31 @@ Constness is shallow. If a `T` in `Types` is some reference type `X&`,
|
|
| 39 |
the return type is `X&`, not `const X&`. However, if the element type is
|
| 40 |
non-reference type `T`, the return type is `const T&`. This is
|
| 41 |
consistent with how constness is defined to work for member variables of
|
| 42 |
reference type.
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
The reason `get` is a nonmember function is that if this functionality
|
| 45 |
had been provided as a member function, code where the type depended on
|
| 46 |
a template parameter would have required using the `template` keyword.
|
| 47 |
|
|
|
|
| 1 |
#### Element access <a id="tuple.elem">[[tuple.elem]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template <size_t I, class... Types>
|
| 5 |
+
constexpr tuple_element_t<I, tuple<Types...> >& get(tuple<Types...>& t) noexcept;
|
| 6 |
```
|
| 7 |
|
| 8 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 9 |
out of bounds.
|
| 10 |
|
| 11 |
*Returns:* A reference to the `I`th element of `t`, where indexing is
|
| 12 |
zero-based.
|
| 13 |
|
| 14 |
``` cpp
|
| 15 |
+
template <size_t I, class... Types>
|
| 16 |
+
constexpr tuple_element_t<I, tuple<Types...> >&& get(tuple<Types...>&& t) noexcept;
|
| 17 |
```
|
| 18 |
|
| 19 |
*Effects:* Equivalent to
|
| 20 |
`return std::forward<typename tuple_element<I, tuple<Types...> >`
|
| 21 |
`::type&&>(get<I>(t));`
|
|
|
|
| 24 |
is `X&`, not `X&&`. However, if the element type is a non-reference type
|
| 25 |
`T`, the return type is `T&&`.
|
| 26 |
|
| 27 |
``` cpp
|
| 28 |
template <size_t I, class... Types>
|
| 29 |
+
constexpr tuple_element_t<I, tuple<Types...> > const& get(const tuple<Types...>& t) noexcept;
|
| 30 |
```
|
| 31 |
|
| 32 |
*Requires:* `I < sizeof...(Types)`. The program is ill-formed if `I` is
|
| 33 |
out of bounds.
|
| 34 |
|
|
|
|
| 39 |
the return type is `X&`, not `const X&`. However, if the element type is
|
| 40 |
non-reference type `T`, the return type is `const T&`. This is
|
| 41 |
consistent with how constness is defined to work for member variables of
|
| 42 |
reference type.
|
| 43 |
|
| 44 |
+
``` cpp
|
| 45 |
+
template <class T, class... Types>
|
| 46 |
+
constexpr T& get(tuple<Types...>& t) noexcept;
|
| 47 |
+
template <class T, class... Types>
|
| 48 |
+
constexpr T&& get(tuple<Types...>&& t) noexcept;
|
| 49 |
+
template <class T, class... Types>
|
| 50 |
+
constexpr const T& get(const tuple<Types...>& t) noexcept;
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
*Requires:* The type `T` occurs exactly once in `Types...`. Otherwise,
|
| 54 |
+
the program is ill-formed.
|
| 55 |
+
|
| 56 |
+
*Returns:* A reference to the element of `t` corresponding to the type
|
| 57 |
+
`T` in `Types...`.
|
| 58 |
+
|
| 59 |
+
``` cpp
|
| 60 |
+
const tuple<int, const int, double, double> t(1, 2, 3.4, 5.6);
|
| 61 |
+
const int &i1 = get<int>(t); // OK. Not ambiguous. i1 == 1
|
| 62 |
+
const int &i2 = get<const int>(t); // OK. Not ambiguous. i2 == 2
|
| 63 |
+
const double &d = get<double>(t); // ERROR. ill-formed
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
The reason `get` is a nonmember function is that if this functionality
|
| 67 |
had been provided as a member function, code where the type depended on
|
| 68 |
a template parameter would have required using the `template` keyword.
|
| 69 |
|