@@ -129,14 +129,23 @@ constexpr auto test_default_copy_assignment_from_non_empty(auto const make) -> v
129
129
BOUNDED_ASSERT (containers::equal (target, Container ()));
130
130
}
131
131
template <typename Container>
132
- constexpr auto test_copy_assignment_from_moved_from (auto const make) -> void {
132
+ constexpr auto test_copy_assignment_from_move_constructed_from (auto const make) -> void {
133
133
auto target = Container (make ());
134
134
auto const source = std::move (target);
135
135
target = source;
136
136
BOUNDED_ASSERT (containers::equal (target, make ()));
137
137
BOUNDED_ASSERT (containers::equal (target, source));
138
138
}
139
139
template <typename Container>
140
+ constexpr auto test_copy_assignment_from_move_assigned_from (auto const make) -> void {
141
+ auto target = Container (make ());
142
+ auto source = Container (make ());
143
+ source = std::move (target);
144
+ target = source;
145
+ BOUNDED_ASSERT (containers::equal (target, make ()));
146
+ BOUNDED_ASSERT (containers::equal (target, source));
147
+ }
148
+ template <typename Container>
140
149
constexpr auto test_self_copy_assignment (auto const make) -> void {
141
150
auto copy = Container (make ());
142
151
// Turn off compiler warning for self assignment
@@ -146,11 +155,14 @@ constexpr auto test_self_copy_assignment(auto const make) -> void {
146
155
}
147
156
template <typename Container>
148
157
constexpr auto test_copy_assignment (auto const make) -> void {
149
- test_copy_assignment_from_empty<Container>(make);
158
+ if constexpr (bounded::default_constructible<Container>) {
159
+ test_copy_assignment_from_empty<Container>(make);
160
+ test_default_copy_assignment_from_empty<Container>();
161
+ test_default_copy_assignment_from_non_empty<Container>(make);
162
+ }
150
163
test_copy_assignment_from_non_empty<Container>(make);
151
- test_default_copy_assignment_from_empty<Container>();
152
- test_default_copy_assignment_from_non_empty<Container>(make);
153
- test_copy_assignment_from_moved_from<Container>(make);
164
+ test_copy_assignment_from_move_constructed_from<Container>(make);
165
+ test_copy_assignment_from_move_assigned_from<Container>(make);
154
166
test_self_copy_assignment<Container>(make);
155
167
}
156
168
@@ -169,13 +181,21 @@ constexpr auto test_move_assignment_from_non_empty(auto const make) -> void {
169
181
BOUNDED_ASSERT (containers::equal (target, make ()));
170
182
}
171
183
template <typename Container>
172
- constexpr auto test_move_assignment_from_moved_from (auto const make) -> void {
184
+ constexpr auto test_move_assignment_from_move_constructed_from (auto const make) -> void {
173
185
auto target = Container (make ());
174
186
auto temp = std::move (target);
175
187
target = std::move (temp);
176
188
BOUNDED_ASSERT (containers::equal (target, make ()));
177
189
}
178
190
template <typename Container>
191
+ constexpr auto test_move_assignment_from_move_assigned_from (auto const make) -> void {
192
+ auto target = Container (make ());
193
+ auto temp = Container (make ());
194
+ temp = std::move (target);
195
+ target = std::move (temp);
196
+ BOUNDED_ASSERT (containers::equal (target, make ()));
197
+ }
198
+ template <typename Container>
179
199
constexpr auto test_recover_from_self_move (auto const make, auto const & validate) -> void {
180
200
auto container = Container (make ());
181
201
container = std::move (container);
@@ -194,9 +214,12 @@ constexpr auto test_self_move_assignment(auto const make, auto const & validate)
194
214
}
195
215
template <typename Container>
196
216
constexpr auto test_move_assignment (auto const make) -> void {
197
- test_move_assignment_from_empty<Container>(make);
217
+ if constexpr (bounded::default_constructible<Container>) {
218
+ test_move_assignment_from_empty<Container>(make);
219
+ }
198
220
test_move_assignment_from_non_empty<Container>(make);
199
- test_move_assignment_from_moved_from<Container>(make);
221
+ test_move_assignment_from_move_constructed_from<Container>(make);
222
+ test_move_assignment_from_move_assigned_from<Container>(make);
200
223
test_self_move_assignment<Container>(make, [&](Container const & container) { return containers::equal (container, make ()); });
201
224
}
202
225
@@ -240,7 +263,9 @@ constexpr auto test_special_members(auto const make) -> bool {
240
263
test_copy_assignment<Container>(make);
241
264
}
242
265
}
243
- test_assignment_from_empty_braces<Container>(make);
266
+ if constexpr (bounded::default_constructible<Container>) {
267
+ test_assignment_from_empty_braces<Container>(make);
268
+ }
244
269
test_swap (make);
245
270
return true ;
246
271
}
@@ -256,14 +281,16 @@ constexpr auto test_sequence_container() -> bool {
256
281
static_assert (containers::is_container<Container>);
257
282
test_forward_range_concepts<Container>();
258
283
259
- test_range_based_for_loop<Container>();
284
+ if constexpr (bounded::default_constructible<Container>) {
285
+ test_range_based_for_loop<Container>();
260
286
261
- test_sequence_container_default_constructed_empty<Container>();
262
- test_sequence_container_implicit_from_two_empty_braces<Container>();
287
+ test_sequence_container_default_constructed_empty<Container>();
288
+ test_sequence_container_implicit_from_two_empty_braces<Container>();
263
289
264
- test_sequence_container_from<Container>([] {
265
- return containers::to_array<containers::range_value_t <Container>>({});
266
- });
290
+ test_sequence_container_from<Container>([] {
291
+ return containers::to_array<containers::range_value_t <Container>>({});
292
+ });
293
+ }
267
294
test_sequence_container_from<Container>([] {
268
295
return containers::to_array<containers::range_value_t <Container>>({5 });
269
296
});
0 commit comments