tmp/tmp1tqp8ndd/{from.md → to.md}
RENAMED
|
@@ -22,14 +22,14 @@ namespace std {
|
|
| 22 |
T1 first;
|
| 23 |
T2 second;
|
| 24 |
pair(const pair&) = default;
|
| 25 |
pair(pair&&) = default;
|
| 26 |
constexpr pair();
|
| 27 |
-
pair(const T1& x, const T2& y);
|
| 28 |
-
template<class U, class V> pair(U&& x, V&& y);
|
| 29 |
-
template<class U, class V> pair(const pair<U, V>& p);
|
| 30 |
-
template<class U, class V> pair(pair<U, V>&& p);
|
| 31 |
template <class... Args1, class... Args2>
|
| 32 |
pair(piecewise_construct_t,
|
| 33 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 34 |
|
| 35 |
pair& operator=(const pair& p);
|
|
@@ -40,14 +40,19 @@ namespace std {
|
|
| 40 |
void swap(pair& p) noexcept(see below);
|
| 41 |
};
|
| 42 |
}
|
| 43 |
```
|
| 44 |
|
| 45 |
-
Constructors and member
|
| 46 |
unless one of the element-wise operations specified to be called for
|
| 47 |
that operation throws an exception.
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
``` cpp
|
| 50 |
constexpr pair();
|
| 51 |
```
|
| 52 |
|
| 53 |
*Requires:* `is_default_constructible<first_type>::value` is `true` and
|
|
@@ -55,21 +60,21 @@ constexpr pair();
|
|
| 55 |
`ible<second_type>::value` is `true`.
|
| 56 |
|
| 57 |
*Effects:* Value-initializes `first` and `second`.
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
-
pair(const T1& x, const T2& y);
|
| 61 |
```
|
| 62 |
|
| 63 |
*Requires:* `is_copy_constructible<first_type>::value` is `true` and
|
| 64 |
`is_copy_constructible<second_type>::value` is `true`.
|
| 65 |
|
| 66 |
*Effects:* The constructor initializes `first` with `x` and `second`
|
| 67 |
with `y`.
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
-
template<class U, class V> pair(U&& x, V&& y);
|
| 71 |
```
|
| 72 |
|
| 73 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 74 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 75 |
|
|
@@ -79,11 +84,11 @@ and `second` with `std::forward<V>(y)`.
|
|
| 79 |
*Remarks:* If `U` is not implicitly convertible to `first_type` or `V`
|
| 80 |
is not implicitly convertible to `second_type` this constructor shall
|
| 81 |
not participate in overload resolution.
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
template<class U, class V> pair(const pair<U, V>& p);
|
| 85 |
```
|
| 86 |
|
| 87 |
*Requires:* `is_constructible<first_type, const U&>::value` is `true`
|
| 88 |
and `is_constructible<second_type, const V&>::value` is `true`.
|
| 89 |
|
|
@@ -93,11 +98,11 @@ argument.
|
|
| 93 |
This constructor shall not participate in overload resolution unless
|
| 94 |
`const U&` is implicitly convertible to `first_type` and `const V&` is
|
| 95 |
implicitly convertible to `second_type`.
|
| 96 |
|
| 97 |
``` cpp
|
| 98 |
-
template<class U, class V> pair(pair<U, V>&& p);
|
| 99 |
```
|
| 100 |
|
| 101 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 102 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 103 |
|
|
@@ -113,13 +118,12 @@ convertible to `second_type`.
|
|
| 113 |
template<class... Args1, class... Args2>
|
| 114 |
pair(piecewise_construct_t,
|
| 115 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 116 |
```
|
| 117 |
|
| 118 |
-
*Requires:*
|
| 119 |
-
`is_constructible<
|
| 120 |
-
`is_constructible<second_type, Args2&&...>::value` is `true`.
|
| 121 |
|
| 122 |
*Effects:* The constructor initializes `first` with arguments of types
|
| 123 |
`Args1...` obtained by forwarding the elements of `first_args` and
|
| 124 |
initializes `second` with arguments of types `Args2...` obtained by
|
| 125 |
forwarding the elements of `second_args`. (Here, forwarding an element
|
|
@@ -141,12 +145,12 @@ pair& operator=(const pair& p);
|
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
template<class U, class V> pair& operator=(const pair<U, V>& p);
|
| 144 |
```
|
| 145 |
|
| 146 |
-
*Requires:* is_assignable
|
| 147 |
-
is_assignable
|
| 148 |
|
| 149 |
*Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
|
| 150 |
|
| 151 |
*Returns:* `*this`.
|
| 152 |
|
|
@@ -202,47 +206,47 @@ swappable with `p.second`.
|
|
| 202 |
|
| 203 |
### Specialized algorithms <a id="pairs.spec">[[pairs.spec]]</a>
|
| 204 |
|
| 205 |
``` cpp
|
| 206 |
template <class T1, class T2>
|
| 207 |
-
bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 208 |
```
|
| 209 |
|
| 210 |
*Returns:* `x.first == y.first && x.second == y.second`.
|
| 211 |
|
| 212 |
``` cpp
|
| 213 |
template <class T1, class T2>
|
| 214 |
-
bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 215 |
```
|
| 216 |
|
| 217 |
*Returns:*
|
| 218 |
`x.first < y.first || (!(y.first < x.first) && x.second < y.second)`.
|
| 219 |
|
| 220 |
``` cpp
|
| 221 |
template <class T1, class T2>
|
| 222 |
-
bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 223 |
```
|
| 224 |
|
| 225 |
*Returns:* `!(x == y)`
|
| 226 |
|
| 227 |
``` cpp
|
| 228 |
template <class T1, class T2>
|
| 229 |
-
bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 230 |
```
|
| 231 |
|
| 232 |
*Returns:* `y < x`
|
| 233 |
|
| 234 |
``` cpp
|
| 235 |
template <class T1, class T2>
|
| 236 |
-
bool operator>=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 237 |
```
|
| 238 |
|
| 239 |
*Returns:* `!(x < y)`
|
| 240 |
|
| 241 |
``` cpp
|
| 242 |
template <class T1, class T2>
|
| 243 |
-
bool operator<=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 244 |
```
|
| 245 |
|
| 246 |
*Returns:* `!(y < x)`
|
| 247 |
|
| 248 |
``` cpp
|
|
@@ -252,17 +256,17 @@ template<class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y)
|
|
| 252 |
|
| 253 |
*Effects:* `x.swap(y)`
|
| 254 |
|
| 255 |
``` cpp
|
| 256 |
template <class T1, class T2>
|
| 257 |
-
pair<V1, V2> make_pair(T1&& x, T2&& y);
|
| 258 |
```
|
| 259 |
|
| 260 |
*Returns:* `pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))`;
|
| 261 |
|
| 262 |
-
where `V1` and `V2` are determined as follows: Let `Ui` be
|
| 263 |
-
|
| 264 |
`reference_wrapper<X>`, otherwise `Vi` is `Ui`.
|
| 265 |
|
| 266 |
In place of:
|
| 267 |
|
| 268 |
``` cpp
|
|
@@ -276,17 +280,15 @@ return make_pair(5, 3.1415926); // types are deduced
|
|
| 276 |
```
|
| 277 |
|
| 278 |
### Tuple-like access to pair <a id="pair.astuple">[[pair.astuple]]</a>
|
| 279 |
|
| 280 |
``` cpp
|
| 281 |
-
|
|
|
|
|
|
|
| 282 |
```
|
| 283 |
|
| 284 |
-
*Returns:* Integral constant expression.
|
| 285 |
-
|
| 286 |
-
*Value:* 2.
|
| 287 |
-
|
| 288 |
``` cpp
|
| 289 |
tuple_element<0, pair<T1, T2> >::type
|
| 290 |
```
|
| 291 |
|
| 292 |
*Value:* the type `T1`.
|
|
@@ -297,32 +299,79 @@ tuple_element<1, pair<T1, T2> >::type
|
|
| 297 |
|
| 298 |
*Value:* the type T2.
|
| 299 |
|
| 300 |
``` cpp
|
| 301 |
template<size_t I, class T1, class T2>
|
| 302 |
-
|
|
|
|
| 303 |
template<size_t I, class T1, class T2>
|
| 304 |
-
const
|
|
|
|
| 305 |
```
|
| 306 |
|
| 307 |
*Returns:* If `I == 0` returns `p.first`; if `I == 1` returns
|
| 308 |
`p.second`; otherwise the program is ill-formed.
|
| 309 |
|
| 310 |
``` cpp
|
| 311 |
template<size_t I, class T1, class T2>
|
| 312 |
-
|
|
|
|
| 313 |
```
|
| 314 |
|
| 315 |
*Returns:* If `I == 0` returns `std::forward<T1&&>(p.first)`; if
|
| 316 |
`I == 1` returns `std::forward<T2&&>(p.second)`; otherwise the program
|
| 317 |
is ill-formed.
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
### Piecewise construction <a id="pair.piecewise">[[pair.piecewise]]</a>
|
| 320 |
|
| 321 |
``` cpp
|
| 322 |
struct piecewise_construct_t { };
|
| 323 |
-
constexpr piecewise_construct_t piecewise_construct
|
| 324 |
```
|
| 325 |
|
| 326 |
The `struct` `piecewise_construct_t` is an empty structure type used as
|
| 327 |
a unique type to disambiguate constructor and function overloading.
|
| 328 |
Specifically, `pair` has a constructor with `piecewise_construct_t` as
|
|
|
|
| 22 |
T1 first;
|
| 23 |
T2 second;
|
| 24 |
pair(const pair&) = default;
|
| 25 |
pair(pair&&) = default;
|
| 26 |
constexpr pair();
|
| 27 |
+
constexpr pair(const T1& x, const T2& y);
|
| 28 |
+
template<class U, class V> constexpr pair(U&& x, V&& y);
|
| 29 |
+
template<class U, class V> constexpr pair(const pair<U, V>& p);
|
| 30 |
+
template<class U, class V> constexpr pair(pair<U, V>&& p);
|
| 31 |
template <class... Args1, class... Args2>
|
| 32 |
pair(piecewise_construct_t,
|
| 33 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 34 |
|
| 35 |
pair& operator=(const pair& p);
|
|
|
|
| 40 |
void swap(pair& p) noexcept(see below);
|
| 41 |
};
|
| 42 |
}
|
| 43 |
```
|
| 44 |
|
| 45 |
+
Constructors and member functions of `pair` shall not throw exceptions
|
| 46 |
unless one of the element-wise operations specified to be called for
|
| 47 |
that operation throws an exception.
|
| 48 |
|
| 49 |
+
The defaulted move and copy constructor, respectively, of pair shall be
|
| 50 |
+
a `constexpr` function if and only if all required element-wise
|
| 51 |
+
initializations for copy and move, respectively, would satisfy the
|
| 52 |
+
requirements for a `constexpr` function.
|
| 53 |
+
|
| 54 |
``` cpp
|
| 55 |
constexpr pair();
|
| 56 |
```
|
| 57 |
|
| 58 |
*Requires:* `is_default_constructible<first_type>::value` is `true` and
|
|
|
|
| 60 |
`ible<second_type>::value` is `true`.
|
| 61 |
|
| 62 |
*Effects:* Value-initializes `first` and `second`.
|
| 63 |
|
| 64 |
``` cpp
|
| 65 |
+
constexpr pair(const T1& x, const T2& y);
|
| 66 |
```
|
| 67 |
|
| 68 |
*Requires:* `is_copy_constructible<first_type>::value` is `true` and
|
| 69 |
`is_copy_constructible<second_type>::value` is `true`.
|
| 70 |
|
| 71 |
*Effects:* The constructor initializes `first` with `x` and `second`
|
| 72 |
with `y`.
|
| 73 |
|
| 74 |
``` cpp
|
| 75 |
+
template<class U, class V> constexpr pair(U&& x, V&& y);
|
| 76 |
```
|
| 77 |
|
| 78 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 79 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 80 |
|
|
|
|
| 84 |
*Remarks:* If `U` is not implicitly convertible to `first_type` or `V`
|
| 85 |
is not implicitly convertible to `second_type` this constructor shall
|
| 86 |
not participate in overload resolution.
|
| 87 |
|
| 88 |
``` cpp
|
| 89 |
+
template<class U, class V> constexpr pair(const pair<U, V>& p);
|
| 90 |
```
|
| 91 |
|
| 92 |
*Requires:* `is_constructible<first_type, const U&>::value` is `true`
|
| 93 |
and `is_constructible<second_type, const V&>::value` is `true`.
|
| 94 |
|
|
|
|
| 98 |
This constructor shall not participate in overload resolution unless
|
| 99 |
`const U&` is implicitly convertible to `first_type` and `const V&` is
|
| 100 |
implicitly convertible to `second_type`.
|
| 101 |
|
| 102 |
``` cpp
|
| 103 |
+
template<class U, class V> constexpr pair(pair<U, V>&& p);
|
| 104 |
```
|
| 105 |
|
| 106 |
*Requires:* `is_constructible<first_type, U&&>::value` is `true` and
|
| 107 |
`is_constructible<second_type, V&&>::value` is `true`.
|
| 108 |
|
|
|
|
| 118 |
template<class... Args1, class... Args2>
|
| 119 |
pair(piecewise_construct_t,
|
| 120 |
tuple<Args1...> first_args, tuple<Args2...> second_args);
|
| 121 |
```
|
| 122 |
|
| 123 |
+
*Requires:* `is_constructible<first_type, Args1&&...>::value` is `true`
|
| 124 |
+
and `is_constructible<second_type, Args2&&...>::value` is `true`.
|
|
|
|
| 125 |
|
| 126 |
*Effects:* The constructor initializes `first` with arguments of types
|
| 127 |
`Args1...` obtained by forwarding the elements of `first_args` and
|
| 128 |
initializes `second` with arguments of types `Args2...` obtained by
|
| 129 |
forwarding the elements of `second_args`. (Here, forwarding an element
|
|
|
|
| 145 |
|
| 146 |
``` cpp
|
| 147 |
template<class U, class V> pair& operator=(const pair<U, V>& p);
|
| 148 |
```
|
| 149 |
|
| 150 |
+
*Requires:* `is_assignable<first_type&, const U&>::value` is `true` and
|
| 151 |
+
`is_assignable<second_type&, const V&>::value` is `true`.
|
| 152 |
|
| 153 |
*Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
|
| 154 |
|
| 155 |
*Returns:* `*this`.
|
| 156 |
|
|
|
|
| 206 |
|
| 207 |
### Specialized algorithms <a id="pairs.spec">[[pairs.spec]]</a>
|
| 208 |
|
| 209 |
``` cpp
|
| 210 |
template <class T1, class T2>
|
| 211 |
+
constexpr bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 212 |
```
|
| 213 |
|
| 214 |
*Returns:* `x.first == y.first && x.second == y.second`.
|
| 215 |
|
| 216 |
``` cpp
|
| 217 |
template <class T1, class T2>
|
| 218 |
+
constexpr bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 219 |
```
|
| 220 |
|
| 221 |
*Returns:*
|
| 222 |
`x.first < y.first || (!(y.first < x.first) && x.second < y.second)`.
|
| 223 |
|
| 224 |
``` cpp
|
| 225 |
template <class T1, class T2>
|
| 226 |
+
constexpr bool operator!=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 227 |
```
|
| 228 |
|
| 229 |
*Returns:* `!(x == y)`
|
| 230 |
|
| 231 |
``` cpp
|
| 232 |
template <class T1, class T2>
|
| 233 |
+
constexpr bool operator>(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 234 |
```
|
| 235 |
|
| 236 |
*Returns:* `y < x`
|
| 237 |
|
| 238 |
``` cpp
|
| 239 |
template <class T1, class T2>
|
| 240 |
+
constexpr bool operator>=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 241 |
```
|
| 242 |
|
| 243 |
*Returns:* `!(x < y)`
|
| 244 |
|
| 245 |
``` cpp
|
| 246 |
template <class T1, class T2>
|
| 247 |
+
constexpr bool operator<=(const pair<T1, T2>& x, const pair<T1, T2>& y);
|
| 248 |
```
|
| 249 |
|
| 250 |
*Returns:* `!(y < x)`
|
| 251 |
|
| 252 |
``` cpp
|
|
|
|
| 256 |
|
| 257 |
*Effects:* `x.swap(y)`
|
| 258 |
|
| 259 |
``` cpp
|
| 260 |
template <class T1, class T2>
|
| 261 |
+
constexpr pair<V1, V2> make_pair(T1&& x, T2&& y);
|
| 262 |
```
|
| 263 |
|
| 264 |
*Returns:* `pair<V1, V2>(std::forward<T1>(x), std::forward<T2>(y))`;
|
| 265 |
|
| 266 |
+
where `V1` and `V2` are determined as follows: Let `Ui` be `decay_t<Ti>`
|
| 267 |
+
for each `Ti`. Then each `Vi` is `X&` if `Ui` equals
|
| 268 |
`reference_wrapper<X>`, otherwise `Vi` is `Ui`.
|
| 269 |
|
| 270 |
In place of:
|
| 271 |
|
| 272 |
``` cpp
|
|
|
|
| 280 |
```
|
| 281 |
|
| 282 |
### Tuple-like access to pair <a id="pair.astuple">[[pair.astuple]]</a>
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
+
template <class T1, class T2>
|
| 286 |
+
struct tuple_size<pair<T1, T2>>
|
| 287 |
+
: integral_constant<size_t, 2> { };
|
| 288 |
```
|
| 289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
``` cpp
|
| 291 |
tuple_element<0, pair<T1, T2> >::type
|
| 292 |
```
|
| 293 |
|
| 294 |
*Value:* the type `T1`.
|
|
|
|
| 299 |
|
| 300 |
*Value:* the type T2.
|
| 301 |
|
| 302 |
``` cpp
|
| 303 |
template<size_t I, class T1, class T2>
|
| 304 |
+
constexpr tuple_element_t<I, pair<T1, T2>>&
|
| 305 |
+
get(pair<T1, T2>& p) noexcept;
|
| 306 |
template<size_t I, class T1, class T2>
|
| 307 |
+
constexpr const tuple_element_t<I, pair<T1, T2>>&
|
| 308 |
+
get(const pair<T1, T2>& p) noexcept;
|
| 309 |
```
|
| 310 |
|
| 311 |
*Returns:* If `I == 0` returns `p.first`; if `I == 1` returns
|
| 312 |
`p.second`; otherwise the program is ill-formed.
|
| 313 |
|
| 314 |
``` cpp
|
| 315 |
template<size_t I, class T1, class T2>
|
| 316 |
+
constexpr tuple_element_t<I, pair<T1, T2>>&&
|
| 317 |
+
get(pair<T1, T2>&& p) noexcept;
|
| 318 |
```
|
| 319 |
|
| 320 |
*Returns:* If `I == 0` returns `std::forward<T1&&>(p.first)`; if
|
| 321 |
`I == 1` returns `std::forward<T2&&>(p.second)`; otherwise the program
|
| 322 |
is ill-formed.
|
| 323 |
|
| 324 |
+
``` cpp
|
| 325 |
+
template <class T, class U>
|
| 326 |
+
constexpr T& get(pair<T, U>& p) noexcept;
|
| 327 |
+
template <class T, class U>
|
| 328 |
+
constexpr const T& get(const pair<T, U>& p) noexcept;
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 332 |
+
ill-formed.
|
| 333 |
+
|
| 334 |
+
*Returns:* `get<0>(p);`
|
| 335 |
+
|
| 336 |
+
``` cpp
|
| 337 |
+
template <class T, class U>
|
| 338 |
+
constexpr T&& get(pair<T, U>&& p) noexcept;
|
| 339 |
+
```
|
| 340 |
+
|
| 341 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 342 |
+
ill-formed.
|
| 343 |
+
|
| 344 |
+
*Returns:* `get<0>(std::move(p));`
|
| 345 |
+
|
| 346 |
+
``` cpp
|
| 347 |
+
template <class T, class U>
|
| 348 |
+
constexpr T& get(pair<U, T>& p) noexcept;
|
| 349 |
+
template <class T, class U>
|
| 350 |
+
constexpr const T& get(const pair<U, T>& p) noexcept;
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 354 |
+
ill-formed.
|
| 355 |
+
|
| 356 |
+
*Returns:* `get<1>(p);`
|
| 357 |
+
|
| 358 |
+
``` cpp
|
| 359 |
+
template <class T, class U>
|
| 360 |
+
constexpr T&& get(pair<U, T>&& p) noexcept;
|
| 361 |
+
```
|
| 362 |
+
|
| 363 |
+
*Requires:* `T` and `U` are distinct types. Otherwise, the program is
|
| 364 |
+
ill-formed.
|
| 365 |
+
|
| 366 |
+
*Returns:* `get<1>(std::move(p));`
|
| 367 |
+
|
| 368 |
### Piecewise construction <a id="pair.piecewise">[[pair.piecewise]]</a>
|
| 369 |
|
| 370 |
``` cpp
|
| 371 |
struct piecewise_construct_t { };
|
| 372 |
+
constexpr piecewise_construct_t piecewise_construct{};
|
| 373 |
```
|
| 374 |
|
| 375 |
The `struct` `piecewise_construct_t` is an empty structure type used as
|
| 376 |
a unique type to disambiguate constructor and function overloading.
|
| 377 |
Specifically, `pair` has a constructor with `piecewise_construct_t` as
|