tmp/tmpo0ikz49k/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
###
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<size_t I, class... Types>
|
| 5 |
constexpr tuple_element_t<I, tuple<Types...>>&
|
| 6 |
get(tuple<Types...>& t) noexcept;
|
|
@@ -12,25 +12,24 @@ template <size_t I, class... Types>
|
|
| 12 |
get(const tuple<Types...>& t) noexcept; // Note B
|
| 13 |
template<size_t I, class... Types>
|
| 14 |
constexpr const tuple_element_t<I, tuple<Types...>>&& get(const tuple<Types...>&& t) noexcept;
|
| 15 |
```
|
| 16 |
|
| 17 |
-
*
|
| 18 |
-
out of bounds.
|
| 19 |
|
| 20 |
-
*Returns:* A reference to the `I`
|
| 21 |
zero-based.
|
| 22 |
|
| 23 |
-
[*Note 1*: \[Note A\]If a `T` in `Types` is some reference type
|
| 24 |
-
the return type is `X&`, not `X&&`. However, if the element type
|
| 25 |
-
non-reference type `T`, the return type is `T&&`. — *end note*]
|
| 26 |
|
| 27 |
-
[*Note 2*: \[Note B\]Constness is shallow. If a `T` in `Types` is
|
| 28 |
-
reference type `X&`, the return type is `X&`, not `const X&`.
|
| 29 |
-
if the element type is a non-reference type `T`, the return
|
| 30 |
-
`const T&`. This is consistent with how constness is defined to
|
| 31 |
-
member variables of reference type. — *end note*]
|
| 32 |
|
| 33 |
``` cpp
|
| 34 |
template<class T, class... Types>
|
| 35 |
constexpr T& get(tuple<Types...>& t) noexcept;
|
| 36 |
template<class T, class... Types>
|
|
@@ -39,23 +38,22 @@ template <class T, class... Types>
|
|
| 39 |
constexpr const T& get(const tuple<Types...>& t) noexcept;
|
| 40 |
template<class T, class... Types>
|
| 41 |
constexpr const T&& get(const tuple<Types...>&& t) noexcept;
|
| 42 |
```
|
| 43 |
|
| 44 |
-
*
|
| 45 |
-
the program is ill-formed.
|
| 46 |
|
| 47 |
*Returns:* A reference to the element of `t` corresponding to the type
|
| 48 |
-
`T` in `Types
|
| 49 |
|
| 50 |
[*Example 1*:
|
| 51 |
|
| 52 |
``` cpp
|
| 53 |
const tuple<int, const int, double, double> t(1, 2, 3.4, 5.6);
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
```
|
| 58 |
|
| 59 |
— *end example*]
|
| 60 |
|
| 61 |
[*Note 1*: The reason `get` is a non-member function is that if this
|
|
|
|
| 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...>>&
|
| 6 |
get(tuple<Types...>& t) noexcept;
|
|
|
|
| 12 |
get(const tuple<Types...>& t) noexcept; // Note B
|
| 13 |
template<size_t I, class... Types>
|
| 14 |
constexpr const tuple_element_t<I, tuple<Types...>>&& get(const tuple<Types...>&& t) noexcept;
|
| 15 |
```
|
| 16 |
|
| 17 |
+
*Mandates:* `I` < `sizeof...(Types)`.
|
|
|
|
| 18 |
|
| 19 |
+
*Returns:* A reference to the `I`ᵗʰ element of `t`, where indexing is
|
| 20 |
zero-based.
|
| 21 |
|
| 22 |
+
[*Note 1*: \[Note A\]If a type `T` in `Types` is some reference type
|
| 23 |
+
`X&`, the return type is `X&`, not `X&&`. However, if the element type
|
| 24 |
+
is a non-reference type `T`, the return type is `T&&`. — *end note*]
|
| 25 |
|
| 26 |
+
[*Note 2*: \[Note B\]Constness is shallow. If a type `T` in `Types` is
|
| 27 |
+
some reference type `X&`, the return type is `X&`, not `const X&`.
|
| 28 |
+
However, if the element type is a non-reference type `T`, the return
|
| 29 |
+
type is `const T&`. This is consistent with how constness is defined to
|
| 30 |
+
work for member variables of reference type. — *end note*]
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
template<class T, class... Types>
|
| 34 |
constexpr T& get(tuple<Types...>& t) noexcept;
|
| 35 |
template<class T, class... Types>
|
|
|
|
| 38 |
constexpr const T& get(const tuple<Types...>& t) noexcept;
|
| 39 |
template<class T, class... Types>
|
| 40 |
constexpr const T&& get(const tuple<Types...>&& t) noexcept;
|
| 41 |
```
|
| 42 |
|
| 43 |
+
*Mandates:* The type `T` occurs exactly once in `Types`.
|
|
|
|
| 44 |
|
| 45 |
*Returns:* A reference to the element of `t` corresponding to the type
|
| 46 |
+
`T` in `Types`.
|
| 47 |
|
| 48 |
[*Example 1*:
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
const tuple<int, const int, double, double> t(1, 2, 3.4, 5.6);
|
| 52 |
+
const int& i1 = get<int>(t); // OK, i1 has value 1
|
| 53 |
+
const int& i2 = get<const int>(t); // OK, i2 has value 2
|
| 54 |
+
const double& d = get<double>(t); // error: type double is not unique within t
|
| 55 |
```
|
| 56 |
|
| 57 |
— *end example*]
|
| 58 |
|
| 59 |
[*Note 1*: The reason `get` is a non-member function is that if this
|