From Jason Turner

[pairs.pair]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmplc8bcp8e/{from.md → to.md} +106 -92
tmp/tmplc8bcp8e/{from.md → to.md} RENAMED
@@ -1,196 +1,210 @@
1
  ### Class template `pair` <a id="pairs.pair">[[pairs.pair]]</a>
2
 
3
  ``` cpp
4
- // defined in header <utility>
5
-
6
  namespace std {
7
  template <class T1, class T2>
8
  struct pair {
9
- typedef T1 first_type;
10
- typedef T2 second_type;
11
 
12
  T1 first;
13
  T2 second;
 
14
  pair(const pair&) = default;
15
  pair(pair&&) = default;
16
- constexpr pair();
17
- constexpr pair(const T1& x, const T2& y);
18
- template<class U, class V> constexpr pair(U&& x, V&& y);
19
- template<class U, class V> constexpr pair(const pair<U, V>& p);
20
- template<class U, class V> constexpr pair(pair<U, V>&& p);
21
  template <class... Args1, class... Args2>
22
- pair(piecewise_construct_t,
23
- tuple<Args1...> first_args, tuple<Args2...> second_args);
24
 
25
  pair& operator=(const pair& p);
26
- template<class U, class V> pair& operator=(const pair<U, V>& p);
27
  pair& operator=(pair&& p) noexcept(see below);
28
- template<class U, class V> pair& operator=(pair<U, V>&& p);
29
 
30
  void swap(pair& p) noexcept(see below);
31
  };
 
 
 
32
  }
33
  ```
34
 
35
  Constructors and member functions of `pair` shall not throw exceptions
36
  unless one of the element-wise operations specified to be called for
37
  that operation throws an exception.
38
 
39
- The defaulted move and copy constructor, respectively, of pair shall be
40
- a `constexpr` function if and only if all required element-wise
41
  initializations for copy and move, respectively, would satisfy the
42
- requirements for a `constexpr` function.
 
 
 
43
 
44
  ``` cpp
45
- constexpr pair();
46
  ```
47
 
48
- *Requires:* `is_default_constructible<first_type>::value` is `true` and
49
- `is_default_construct-`
50
- `ible<second_type>::value` is `true`.
51
-
52
  *Effects:* Value-initializes `first` and `second`.
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  ``` cpp
55
- constexpr pair(const T1& x, const T2& y);
56
  ```
57
 
58
- *Requires:* `is_copy_constructible<first_type>::value` is `true` and
59
- `is_copy_constructible<second_type>::value` is `true`.
60
 
61
- *Effects:* The constructor initializes `first` with `x` and `second`
62
- with `y`.
 
 
 
 
63
 
64
  ``` cpp
65
- template<class U, class V> constexpr pair(U&& x, V&& y);
66
  ```
67
 
68
- *Requires:* `is_constructible<first_type, U&&>::value` is `true` and
69
- `is_constructible<second_type, V&&>::value` is `true`.
70
-
71
- *Effects:* The constructor initializes `first` with `std::forward<U>(x)`
72
- and `second` with `std::forward<V>(y)`.
73
 
74
- *Remarks:* If `U` is not implicitly convertible to `first_type` or `V`
75
- is not implicitly convertible to `second_type` this constructor shall
76
- not participate in overload resolution.
 
 
77
 
78
  ``` cpp
79
- template<class U, class V> constexpr pair(const pair<U, V>& p);
80
  ```
81
 
82
- *Requires:* `is_constructible<first_type, const U&>::value` is `true`
83
- and `is_constructible<second_type, const V&>::value` is `true`.
84
-
85
  *Effects:* Initializes members from the corresponding members of the
86
  argument.
87
 
88
- This constructor shall not participate in overload resolution unless
89
- `const U&` is implicitly convertible to `first_type` and `const V&` is
90
- implicitly convertible to `second_type`.
 
 
91
 
92
  ``` cpp
93
- template<class U, class V> constexpr pair(pair<U, V>&& p);
94
  ```
95
 
96
- *Requires:* `is_constructible<first_type, U&&>::value` is `true` and
97
- `is_constructible<second_type, V&&>::value` is `true`.
98
 
99
- *Effects:* The constructor initializes `first` with
100
- `std::forward<U>(p.first)` and `second` with
101
- `std::forward<V>(p.second)`.
102
-
103
- This constructor shall not participate in overload resolution unless `U`
104
- is implicitly convertible to `first_type` and `V` is implicitly
105
- convertible to `second_type`.
106
 
107
  ``` cpp
108
  template<class... Args1, class... Args2>
109
- pair(piecewise_construct_t,
110
- tuple<Args1...> first_args, tuple<Args2...> second_args);
111
  ```
112
 
113
- *Requires:* `is_constructible<first_type, Args1&&...>::value` is `true`
114
- and `is_constructible<second_type, Args2&&...>::value` is `true`.
115
 
116
- *Effects:* The constructor initializes `first` with arguments of types
117
- `Args1...` obtained by forwarding the elements of `first_args` and
118
- initializes `second` with arguments of types `Args2...` obtained by
119
- forwarding the elements of `second_args`. (Here, forwarding an element
120
- `x` of type `U` within a `tuple` object means calling
121
- `std::forward<U>(x)`.) This form of construction, whereby constructor
122
- arguments for `first` and `second` are each provided in a separate
123
- `tuple` object, is called *piecewise construction*.
124
 
125
  ``` cpp
126
  pair& operator=(const pair& p);
127
  ```
128
 
129
- *Requires:* `is_copy_assignable<first_type>::value` is `true` and
130
- `is_copy_assignable<second_type>::value` is `true`.
131
-
132
  *Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
133
 
 
 
 
 
134
  *Returns:* `*this`.
135
 
136
  ``` cpp
137
- template<class U, class V> pair& operator=(const pair<U, V>& p);
138
  ```
139
 
140
- *Requires:* `is_assignable<first_type&, const U&>::value` is `true` and
141
- `is_assignable<second_type&, const V&>::value` is `true`.
142
-
143
  *Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
144
 
 
 
 
 
145
  *Returns:* `*this`.
146
 
147
  ``` cpp
148
  pair& operator=(pair&& p) noexcept(see below);
149
  ```
150
 
151
- *Remarks:* The expression inside `noexcept` is equivalent to:
152
-
153
- ``` cpp
154
- is_nothrow_move_assignable<T1>::value &&
155
- is_nothrow_move_assignable<T2>::value
156
- ```
157
-
158
- *Requires:* `is_move_assignable<first_type>::value` is `true` and
159
- `is_move_assignable<second_type>::value` is `true`.
160
-
161
  *Effects:* Assigns to `first` with `std::forward<first_type>(p.first)`
162
  and to `second` with
163
  `std::forward<second_type>(p.second)`.
164
 
 
 
 
 
 
 
 
 
 
 
165
  *Returns:* `*this`.
166
 
167
  ``` cpp
168
- template<class U, class V> pair& operator=(pair<U, V>&& p);
169
  ```
170
 
171
- *Requires:* `is_assignable<first_type&, U&&>::value` is `true` and
172
- `is_assignable<second_type&, V&&>::value` is `true`.
173
-
174
  *Effects:* Assigns to `first` with `std::forward<U>(p.first)` and to
175
  `second` with
176
  `std::forward<V>(p.second)`.
177
 
 
 
 
 
178
  *Returns:* `*this`.
179
 
180
  ``` cpp
181
  void swap(pair& p) noexcept(see below);
182
  ```
183
 
184
- *Remarks:* The expression inside `noexcept` is equivalent to:
185
-
186
- ``` cpp
187
- noexcept(swap(first, p.first)) &&
188
- noexcept(swap(second, p.second))
189
- ```
190
-
191
  *Requires:* `first` shall be swappable
192
  with ([[swappable.requirements]]) `p.first` and `second` shall be
193
  swappable with `p.second`.
194
 
195
  *Effects:* Swaps `first` with `p.first` and `second` with `p.second`.
196
 
 
 
 
 
 
 
 
1
  ### Class template `pair` <a id="pairs.pair">[[pairs.pair]]</a>
2
 
3
  ``` cpp
 
 
4
  namespace std {
5
  template <class T1, class T2>
6
  struct pair {
7
+ using first_type = T1;
8
+ using second_type = T2;
9
 
10
  T1 first;
11
  T2 second;
12
+
13
  pair(const pair&) = default;
14
  pair(pair&&) = default;
15
+ \EXPLICIT constexpr pair();
16
+ \EXPLICIT constexpr pair(const T1& x, const T2& y);
17
+ template<class U1, class U2> \EXPLICIT constexpr pair(U1&& x, U2&& y);
18
+ template<class U1, class U2> \EXPLICIT constexpr pair(const pair<U1, U2>& p);
19
+ template<class U1, class U2> \EXPLICIT constexpr pair(pair<U1, U2>&& p);
20
  template <class... Args1, class... Args2>
21
+ pair(piecewise_construct_t, tuple<Args1...> first_args, tuple<Args2...> second_args);
 
22
 
23
  pair& operator=(const pair& p);
24
+ template<class U1, class U2> pair& operator=(const pair<U1, U2>& p);
25
  pair& operator=(pair&& p) noexcept(see below);
26
+ template<class U1, class U2> pair& operator=(pair<U1, U2>&& p);
27
 
28
  void swap(pair& p) noexcept(see below);
29
  };
30
+
31
+ template<class T1, class T2>
32
+ pair(T1, T2) -> pair<T1, T2>;
33
  }
34
  ```
35
 
36
  Constructors and member functions of `pair` shall not throw exceptions
37
  unless one of the element-wise operations specified to be called for
38
  that operation throws an exception.
39
 
40
+ The defaulted move and copy constructor, respectively, of `pair` shall
41
+ be a constexpr function if and only if all required element-wise
42
  initializations for copy and move, respectively, would satisfy the
43
+ requirements for a constexpr function. The destructor of `pair` shall be
44
+ a trivial destructor if
45
+ `(is_trivially_destructible_v<T1> && is_trivially_destructible_v<T2>)`
46
+ is `true`.
47
 
48
  ``` cpp
49
+ \EXPLICIT constexpr pair();
50
  ```
51
 
 
 
 
 
52
  *Effects:* Value-initializes `first` and `second`.
53
 
54
+ *Remarks:* This constructor shall not participate in overload resolution
55
+ unless `is_default_constructible_v<first_type>` is `true` and
56
+ `is_default_constructible_v<second_type>` is `true`.
57
+
58
+ [*Note 1*: This behavior can be implemented by a constructor template
59
+ with default template arguments. — *end note*]
60
+
61
+ The constructor is explicit if and only if either `first_type` or
62
+ `second_type` is not implicitly default-constructible.
63
+
64
+ [*Note 2*: This behavior can be implemented with a trait that checks
65
+ whether a `const first_type&` or a `const second_type&` can be
66
+ initialized with `{}`. — *end note*]
67
+
68
  ``` cpp
69
+ \EXPLICIT constexpr pair(const T1& x, const T2& y);
70
  ```
71
 
72
+ *Effects:* Initializes `first` with `x` and `second` with `y`.
 
73
 
74
+ *Remarks:* This constructor shall not participate in overload resolution
75
+ unless `is_copy_constructible_v<first_type>` is `true` and
76
+ `is_copy_constructible_v<second_type>` is `true`. The constructor is
77
+ explicit if and only if
78
+ `is_convertible_v<const first_type&, first_type>` is `false` or
79
+ `is_convertible_v<const second_type&, second_type>` is `false`.
80
 
81
  ``` cpp
82
+ template<class U1, class U2> \EXPLICIT constexpr pair(U1&& x, U2&& y);
83
  ```
84
 
85
+ *Effects:* Initializes `first` with `std::forward<U1>(x)` and `second`
86
+ with `std::forward<U2>(y)`.
 
 
 
87
 
88
+ *Remarks:* This constructor shall not participate in overload resolution
89
+ unless `is_constructible_v<first_type, U1&&>` is `true` and
90
+ `is_constructible_v<second_type, U2&&>` is `true`. The constructor is
91
+ explicit if and only if `is_convertible_v<U1&&, first_type>` is `false`
92
+ or `is_convertible_v<U2&&, second_type>` is `false`.
93
 
94
  ``` cpp
95
+ template<class U1, class U2> \EXPLICIT constexpr pair(const pair<U1, U2>& p);
96
  ```
97
 
 
 
 
98
  *Effects:* Initializes members from the corresponding members of the
99
  argument.
100
 
101
+ *Remarks:* This constructor shall not participate in overload resolution
102
+ unless `is_constructible_v<first_type, const U1&>` is `true` and
103
+ `is_constructible_v<second_type, const U2&>` is `true`. The constructor
104
+ is explicit if and only if `is_convertible_v<const U1&, first_type>` is
105
+ `false` or `is_convertible_v<const U2&, second_type>` is `false`.
106
 
107
  ``` cpp
108
+ template<class U1, class U2> \EXPLICIT constexpr pair(pair<U1, U2>&& p);
109
  ```
110
 
111
+ *Effects:* Initializes `first` with `std::forward<U1>(p.first)` and
112
+ `second` with `std::forward<U2>(p.second)`.
113
 
114
+ *Remarks:* This constructor shall not participate in overload resolution
115
+ unless `is_constructible_v<first_type, U1&&>` is `true` and
116
+ `is_constructible_v<second_type, U2&&>` is `true`. The constructor is
117
+ explicit if and only if `is_convertible_v<U1&&, first_type>` is `false`
118
+ or `is_convertible_v<U2&&, second_type>` is `false`.
 
 
119
 
120
  ``` cpp
121
  template<class... Args1, class... Args2>
122
+ pair(piecewise_construct_t, tuple<Args1...> first_args, tuple<Args2...> second_args);
 
123
  ```
124
 
125
+ *Requires:* `is_constructible_v<first_type, Args1&&...>` is `true` and
126
+ `is_constructible_v<second_type, Args2&&...>` is `true`.
127
 
128
+ *Effects:* Initializes `first` with arguments of types `Args1...`
129
+ obtained by forwarding the elements of `first_args` and initializes
130
+ `second` with arguments of types `Args2...` obtained by forwarding the
131
+ elements of `second_args`. (Here, forwarding an element `x` of type `U`
132
+ within a `tuple` object means calling `std::forward<U>(x)`.) This form
133
+ of construction, whereby constructor arguments for `first` and `second`
134
+ are each provided in a separate `tuple` object, is called *piecewise
135
+ construction*.
136
 
137
  ``` cpp
138
  pair& operator=(const pair& p);
139
  ```
140
 
 
 
 
141
  *Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
142
 
143
+ *Remarks:* This operator shall be defined as deleted unless
144
+ `is_copy_assignable_v<first_type>` is `true` and
145
+ `is_copy_assignable_v<second_type>` is `true`.
146
+
147
  *Returns:* `*this`.
148
 
149
  ``` cpp
150
+ template<class U1, class U2> pair& operator=(const pair<U1, U2>& p);
151
  ```
152
 
 
 
 
153
  *Effects:* Assigns `p.first` to `first` and `p.second` to `second`.
154
 
155
+ *Remarks:* This operator shall not participate in overload resolution
156
+ unless `is_assignable_v<first_type&, const U1&>` is `true` and
157
+ `is_assignable_v<second_type&, const U2&>` is `true`.
158
+
159
  *Returns:* `*this`.
160
 
161
  ``` cpp
162
  pair& operator=(pair&& p) noexcept(see below);
163
  ```
164
 
 
 
 
 
 
 
 
 
 
 
165
  *Effects:* Assigns to `first` with `std::forward<first_type>(p.first)`
166
  and to `second` with
167
  `std::forward<second_type>(p.second)`.
168
 
169
+ *Remarks:* This operator shall be defined as deleted unless
170
+ `is_move_assignable_v<first_type>` is `true` and
171
+ `is_move_assignable_v<second_type>` is `true`.
172
+
173
+ *Remarks:* The expression inside `noexcept` is equivalent to:
174
+
175
+ ``` cpp
176
+ is_nothrow_move_assignable_v<T1> && is_nothrow_move_assignable_v<T2>
177
+ ```
178
+
179
  *Returns:* `*this`.
180
 
181
  ``` cpp
182
+ template<class U1, class U2> pair& operator=(pair<U1, U2>&& p);
183
  ```
184
 
 
 
 
185
  *Effects:* Assigns to `first` with `std::forward<U>(p.first)` and to
186
  `second` with
187
  `std::forward<V>(p.second)`.
188
 
189
+ *Remarks:* This operator shall not participate in overload resolution
190
+ unless `is_assignable_v<first_type&, U1&&>` is `true` and
191
+ `is_assignable_v<second_type&, U2&&>` is `true`.
192
+
193
  *Returns:* `*this`.
194
 
195
  ``` cpp
196
  void swap(pair& p) noexcept(see below);
197
  ```
198
 
 
 
 
 
 
 
 
199
  *Requires:* `first` shall be swappable
200
  with ([[swappable.requirements]]) `p.first` and `second` shall be
201
  swappable with `p.second`.
202
 
203
  *Effects:* Swaps `first` with `p.first` and `second` with `p.second`.
204
 
205
+ *Remarks:* The expression inside `noexcept` is equivalent to:
206
+
207
+ ``` cpp
208
+ is_nothrow_swappable_v<first_type> && is_nothrow_swappable_v<second_type>
209
+ ```
210
+