From Jason Turner

[tuple.cnstr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp7phxjeg8/{from.md → to.md} +109 -84
tmp/tmp7phxjeg8/{from.md → to.md} RENAMED
@@ -1,179 +1,204 @@
1
  #### Construction <a id="tuple.cnstr">[[tuple.cnstr]]</a>
2
 
 
 
 
 
 
3
  For each `tuple` constructor, an exception is thrown only if the
4
  construction of one of the types in `Types` throws an exception.
5
 
6
- The defaulted move and copy constructor, respectively, of `tuple` shall
7
- be a constexpr function if and only if all required element-wise
8
- initializations for copy and move, respectively, would satisfy the
9
  requirements for a constexpr function. The defaulted move and copy
10
- constructor of `tuple<>` shall be constexpr functions.
11
 
12
- The destructor of tuple shall be a trivial destructor if
13
- `(is_trivially_destructible_v<Types> && ...)` is `true`.
14
-
15
- In the constructor descriptions that follow, let i be in the range
16
- \[`0`, `sizeof...(Types)`) in order, `Tᵢ` be the iᵗʰ type in `Types`,
17
- and `Uᵢ` be the iᵗʰ type in a template parameter pack named `UTypes`,
18
- where indexing is zero-based.
19
 
20
  ``` cpp
21
- \EXPLICIT constexpr tuple();
22
  ```
23
 
 
 
24
  *Effects:* Value-initializes each element.
25
 
26
- *Remarks:* This constructor shall not participate in overload resolution
27
- unless `is_default_constructible_v<``Tᵢ``>` is `true` for all i.
 
28
 
29
- [*Note 1*: This behavior can be implemented by a constructor template
30
- with default template arguments. — *end note*]
31
-
32
- The constructor is explicit if and only if `Tᵢ` is not implicitly
33
- default-constructible for at least one i.
34
-
35
- [*Note 2*: This behavior can be implemented with a trait that checks
36
  whether a `const ``Tᵢ``&` can be initialized with `{}`. — *end note*]
37
 
38
  ``` cpp
39
- \EXPLICIT constexpr tuple(const Types&...);
40
  ```
41
 
 
 
 
42
  *Effects:* Initializes each element with the value of the corresponding
43
  parameter.
44
 
45
- *Remarks:* This constructor shall not participate in overload resolution
46
- unless `sizeof...(Types) >= 1` and `is_copy_constructible_v<``Tᵢ``>` is
47
- `true` for all i. The constructor is explicit if and only if
48
- `is_convertible_v<const ``Tᵢ``&, ``Tᵢ``>` is `false` for at least one i.
49
 
50
  ``` cpp
51
- template <class... UTypes> \EXPLICIT constexpr tuple(UTypes&&... u);
52
  ```
53
 
 
 
 
 
 
 
 
 
54
  *Effects:* Initializes the elements in the tuple with the corresponding
55
  value in `std::forward<UTypes>(u)`.
56
 
57
- *Remarks:* This constructor shall not participate in overload resolution
58
- unless `sizeof...(Types)` `==` `sizeof...(UTypes)` and
59
- `sizeof...(Types) >= 1` and `is_constructible_v<``Tᵢ``, ``Uᵢ``&&>` is
60
- `true` for all i. The constructor is explicit if and only if
61
- `is_convertible_v<``Uᵢ``&&, ``Tᵢ``>` is `false` for at least one i.
62
 
63
  ``` cpp
64
  tuple(const tuple& u) = default;
65
  ```
66
 
67
- *Requires:* `is_copy_constructible_v<``Tᵢ``>` is `true` for all i.
68
 
69
  *Effects:* Initializes each element of `*this` with the corresponding
70
  element of `u`.
71
 
72
  ``` cpp
73
  tuple(tuple&& u) = default;
74
  ```
75
 
76
- *Requires:* `is_move_constructible_v<``Tᵢ``>` is `true` for all i.
77
 
78
  *Effects:* For all i, initializes the iᵗʰ element of `*this` with
79
  `std::forward<``Tᵢ``>(get<`i`>(u))`.
80
 
81
  ``` cpp
82
- template <class... UTypes> \EXPLICIT constexpr tuple(const tuple<UTypes...>& u);
83
  ```
84
 
85
- *Effects:* Initializes each element of `*this` with the corresponding
86
- element of `u`.
87
 
88
- *Remarks:* This constructor shall not participate in overload resolution
89
- unless
90
-
91
- - `sizeof...(Types)` `==` `sizeof...(UTypes)` and
92
  - `is_constructible_v<``Tᵢ``, const ``Uᵢ``&>` is `true` for all i, and
93
- - `sizeof...(Types) != 1`, or (when `Types...` expands to `T` and
94
- `UTypes...` expands to `U`)
95
- `!is_convertible_v<const tuple<U>&, T> && !is_constructible_v<T, const tuple<U>&>&& !is_same_v<T, U>`
96
- is `true`.
 
97
 
98
- The constructor is explicit if and only if
99
- `is_convertible_v<const ``Uᵢ``&, ``Tᵢ``>` is `false` for at least one i.
 
 
 
 
 
 
100
 
101
  ``` cpp
102
- template <class... UTypes> \EXPLICIT constexpr tuple(tuple<UTypes...>&& u);
103
  ```
104
 
 
 
 
 
 
 
 
 
 
105
  *Effects:* For all i, initializes the iᵗʰ element of `*this` with
106
  `std::forward<``Uᵢ``>(get<`i`>(u))`.
107
 
108
- *Remarks:* This constructor shall not participate in overload resolution
109
- unless
110
 
111
- - `sizeof...(Types)` `==` `sizeof...(UTypes)`, and
112
- - `is_constructible_v<``Tᵢ``, ``Uᵢ``&&>` is `true` for all i, and
113
- - `sizeof...(Types) != 1`, or (when `Types...` expands to `T` and
114
- `UTypes...` expands to `U`)
115
- `!is_convertible_v<tuple<U>, T> && !is_constructible_v<T, tuple<U>> &&!is_same_v<T, U>`
116
- is `true`.
117
-
118
- The constructor is explicit if and only if
119
- `is_convertible_v<``Uᵢ``&&, ``Tᵢ``>` is `false` for at least one i.
120
 
121
  ``` cpp
122
- template <class U1, class U2> \EXPLICIT constexpr tuple(const pair<U1, U2>& u);
123
  ```
124
 
 
 
 
 
 
 
125
  *Effects:* Initializes the first element with `u.first` and the second
126
  element with `u.second`.
127
 
128
- *Remarks:* This constructor shall not participate in overload resolution
129
- unless `sizeof...(Types) == 2`, `is_constructible_v<``T₀``, const U1&>`
130
- is `true` and `is_constructible_v<``T₁``, const U2&>` is `true`.
131
 
132
- The constructor is explicit if and only if
133
- `is_convertible_v<const U1&, ``T₀``>` is `false` or
134
- `is_convertible_v<const U2&, ``T₁``>` is `false`.
135
 
136
  ``` cpp
137
- template <class U1, class U2> \EXPLICIT constexpr tuple(pair<U1, U2>&& u);
138
  ```
139
 
 
 
 
 
 
 
140
  *Effects:* Initializes the first element with
141
  `std::forward<U1>(u.first)` and the second element with
142
  `std::forward<U2>(u.second)`.
143
 
144
- *Remarks:* This constructor shall not participate in overload resolution
145
- unless `sizeof...(Types) == 2`, `is_constructible_v<``T₀``, U1&&>` is
146
- `true` and `is_constructible_v<``T₁``, U2&&>` is `true`.
147
 
148
- The constructor is explicit if and only if
149
- `is_convertible_v<U1&&, ``T₀``>` is `false` or
150
- `is_convertible_v<U2&&, ``T₁``>` is `false`.
151
 
152
  ``` cpp
153
  template<class Alloc>
 
154
  tuple(allocator_arg_t, const Alloc& a);
155
  template<class Alloc>
156
- \EXPLICIT tuple(allocator_arg_t, const Alloc& a, const Types&...);
 
157
  template<class Alloc, class... UTypes>
158
- \EXPLICIT tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
 
159
  template<class Alloc>
160
- tuple(allocator_arg_t, const Alloc& a, const tuple&);
161
  template<class Alloc>
162
- tuple(allocator_arg_t, const Alloc& a, tuple&&);
163
  template<class Alloc, class... UTypes>
164
- \EXPLICIT tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
 
165
  template<class Alloc, class... UTypes>
166
- \EXPLICIT tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
 
167
  template<class Alloc, class U1, class U2>
168
- \EXPLICIT tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
 
169
  template<class Alloc, class U1, class U2>
170
- \EXPLICIT tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
 
171
  ```
172
 
173
- *Requires:* `Alloc` shall meet the requirements for an
174
- `Allocator` ([[allocator.requirements]]).
175
 
176
  *Effects:* Equivalent to the preceding constructors except that each
177
  element is constructed with uses-allocator
178
- construction ([[allocator.uses.construction]]).
179
 
 
1
  #### Construction <a id="tuple.cnstr">[[tuple.cnstr]]</a>
2
 
3
+ In the descriptions that follow, let i be in the range \[`0`,
4
+ `sizeof...(Types)`) in order, `Tᵢ` be the iᵗʰ type in `Types`, and `Uᵢ`
5
+ be the iᵗʰ type in a template parameter pack named `UTypes`, where
6
+ indexing is zero-based.
7
+
8
  For each `tuple` constructor, an exception is thrown only if the
9
  construction of one of the types in `Types` throws an exception.
10
 
11
+ The defaulted move and copy constructor, respectively, of `tuple` is a
12
+ constexpr function if and only if all required element-wise
13
+ initializations for move and copy, respectively, would satisfy the
14
  requirements for a constexpr function. The defaulted move and copy
15
+ constructor of `tuple<>` are constexpr functions.
16
 
17
+ If `is_trivially_destructible_v<Tᵢ>` is `true` for all `Tᵢ`, then the
18
+ destructor of `tuple` is trivial.
 
 
 
 
 
19
 
20
  ``` cpp
21
+ constexpr explicit(see below) tuple();
22
  ```
23
 
24
+ *Constraints:* `is_default_constructible_v<``Tᵢ``>` is `true` for all i.
25
+
26
  *Effects:* Value-initializes each element.
27
 
28
+ *Remarks:* The expression inside `explicit` evaluates to `true` if and
29
+ only if `Tᵢ` is not copy-list-initializable from an empty list for at
30
+ least one i.
31
 
32
+ [*Note 1*: This behavior can be implemented with a trait that checks
 
 
 
 
 
 
33
  whether a `const ``Tᵢ``&` can be initialized with `{}`. — *end note*]
34
 
35
  ``` cpp
36
+ constexpr explicit(see below) tuple(const Types&...);
37
  ```
38
 
39
+ *Constraints:* `sizeof...(Types)` ≥ 1 and
40
+ `is_copy_constructible_v<``Tᵢ``>` is `true` for all i.
41
+
42
  *Effects:* Initializes each element with the value of the corresponding
43
  parameter.
44
 
45
+ *Remarks:* The expression inside `explicit` is equivalent to:
 
 
 
46
 
47
  ``` cpp
48
+ !conjunction_v<is_convertible<const Types&, Types>...>
49
  ```
50
 
51
+ ``` cpp
52
+ template<class... UTypes> constexpr explicit(see below) tuple(UTypes&&... u);
53
+ ```
54
+
55
+ *Constraints:* `sizeof...(Types)` equals `sizeof...(UTypes)` and
56
+ `sizeof...(Types)` ≥ 1 and `is_constructible_v<``Tᵢ``, ``Uᵢ``>` is
57
+ `true` for all i.
58
+
59
  *Effects:* Initializes the elements in the tuple with the corresponding
60
  value in `std::forward<UTypes>(u)`.
61
 
62
+ *Remarks:* The expression inside `explicit` is equivalent to:
63
+
64
+ ``` cpp
65
+ !conjunction_v<is_convertible<UTypes, Types>...>
66
+ ```
67
 
68
  ``` cpp
69
  tuple(const tuple& u) = default;
70
  ```
71
 
72
+ *Mandates:* `is_copy_constructible_v<``Tᵢ``>` is `true` for all i.
73
 
74
  *Effects:* Initializes each element of `*this` with the corresponding
75
  element of `u`.
76
 
77
  ``` cpp
78
  tuple(tuple&& u) = default;
79
  ```
80
 
81
+ *Constraints:* `is_move_constructible_v<``Tᵢ``>` is `true` for all i.
82
 
83
  *Effects:* For all i, initializes the iᵗʰ element of `*this` with
84
  `std::forward<``Tᵢ``>(get<`i`>(u))`.
85
 
86
  ``` cpp
87
+ template<class... UTypes> constexpr explicit(see below) tuple(const tuple<UTypes...>& u);
88
  ```
89
 
90
+ *Constraints:*
 
91
 
92
+ - `sizeof...(Types)` equals `sizeof...(UTypes)` and
 
 
 
93
  - `is_constructible_v<``Tᵢ``, const ``Uᵢ``&>` is `true` for all i, and
94
+ - either `sizeof...(Types)` is not 1, or (when `Types...` expands to `T`
95
+ and `UTypes...` expands to `U`)
96
+ `is_convertible_v<const tuple<U>&, T>`,
97
+ `is_constructible_v<T, const tuple<U>&>`, and `is_same_v<T, U>` are
98
+ all `false`.
99
 
100
+ *Effects:* Initializes each element of `*this` with the corresponding
101
+ element of `u`.
102
+
103
+ *Remarks:* The expression inside `explicit` is equivalent to:
104
+
105
+ ``` cpp
106
+ !conjunction_v<is_convertible<const UTypes&, Types>...>
107
+ ```
108
 
109
  ``` cpp
110
+ template<class... UTypes> constexpr explicit(see below) tuple(tuple<UTypes...>&& u);
111
  ```
112
 
113
+ *Constraints:*
114
+
115
+ - `sizeof...(Types)` equals `sizeof...(UTypes)`, and
116
+ - `is_constructible_v<``Tᵢ``, ``Uᵢ``>` is `true` for all i, and
117
+ - either `sizeof...(Types)` is not 1, or (when `Types...` expands to `T`
118
+ and `UTypes...` expands to `U`) `is_convertible_v<tuple<U>, T>`,
119
+ `is_constructible_v<T, tuple<U>>`, and `is_same_v<T, U>` are all
120
+ `false`.
121
+
122
  *Effects:* For all i, initializes the iᵗʰ element of `*this` with
123
  `std::forward<``Uᵢ``>(get<`i`>(u))`.
124
 
125
+ *Remarks:* The expression inside `explicit` is equivalent to:
 
126
 
127
+ ``` cpp
128
+ !conjunction_v<is_convertible<UTypes, Types>...>
129
+ ```
 
 
 
 
 
 
130
 
131
  ``` cpp
132
+ template<class U1, class U2> constexpr explicit(see below) tuple(const pair<U1, U2>& u);
133
  ```
134
 
135
+ *Constraints:*
136
+
137
+ - `sizeof...(Types)` is 2,
138
+ - `is_constructible_v<``T₀``, const U1&>` is `true`, and
139
+ - `is_constructible_v<``T₁``, const U2&>` is `true`.
140
+
141
  *Effects:* Initializes the first element with `u.first` and the second
142
  element with `u.second`.
143
 
144
+ The expression inside `explicit` is equivalent to:
 
 
145
 
146
+ ``` cpp
147
+ !is_convertible_v<const U1&, $T_0$> || !is_convertible_v<const U2&, $T_1$>
148
+ ```
149
 
150
  ``` cpp
151
+ template<class U1, class U2> constexpr explicit(see below) tuple(pair<U1, U2>&& u);
152
  ```
153
 
154
+ *Constraints:*
155
+
156
+ - `sizeof...(Types)` is 2,
157
+ - `is_constructible_v<``T₀``, U1>` is `true`, and
158
+ - `is_constructible_v<``T₁``, U2>` is `true`.
159
+
160
  *Effects:* Initializes the first element with
161
  `std::forward<U1>(u.first)` and the second element with
162
  `std::forward<U2>(u.second)`.
163
 
164
+ The expression inside `explicit` is equivalent to:
 
 
165
 
166
+ ``` cpp
167
+ !is_convertible_v<U1, $T_0$> || !is_convertible_v<U2, $T_1$>
168
+ ```
169
 
170
  ``` cpp
171
  template<class Alloc>
172
+ constexpr explicit(see below)
173
  tuple(allocator_arg_t, const Alloc& a);
174
  template<class Alloc>
175
+ constexpr explicit(see below)
176
+ tuple(allocator_arg_t, const Alloc& a, const Types&...);
177
  template<class Alloc, class... UTypes>
178
+ constexpr explicit(see below)
179
+ tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
180
  template<class Alloc>
181
+ constexpr tuple(allocator_arg_t, const Alloc& a, const tuple&);
182
  template<class Alloc>
183
+ constexpr tuple(allocator_arg_t, const Alloc& a, tuple&&);
184
  template<class Alloc, class... UTypes>
185
+ constexpr explicit(see below)
186
+ tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
187
  template<class Alloc, class... UTypes>
188
+ constexpr explicit(see below)
189
+ tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
190
  template<class Alloc, class U1, class U2>
191
+ constexpr explicit(see below)
192
+ tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
193
  template<class Alloc, class U1, class U2>
194
+ constexpr explicit(see below)
195
+ tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
196
  ```
197
 
198
+ *Preconditions:* `Alloc` meets the *Cpp17Allocator* requirements
199
+ ([[cpp17.allocator]]).
200
 
201
  *Effects:* Equivalent to the preceding constructors except that each
202
  element is constructed with uses-allocator
203
+ construction [[allocator.uses.construction]].
204