| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
|
| 3 |
// PR libstdc++/115522 std::to_array no longer works for struct which is |
| 4 |
// trivial but not default constructible |
| 5 |
|
| 6 |
#include <array> |
| 7 |
|
| 8 |
void |
| 9 |
test_deleted_ctor() |
| 10 |
{ |
| 11 |
struct S |
| 12 |
{ |
| 13 |
S() = delete; |
| 14 |
S(int) { } |
| 15 |
}; |
| 16 |
|
| 17 |
S arr[1] = {{1}}; |
| 18 |
auto arr1 = std::to_array(arr); |
| 19 |
auto arr2 = std::to_array(std::move(arr)); |
| 20 |
} |
| 21 |
|
| 22 |
void |
| 23 |
test_deleted_assignment() |
| 24 |
{ |
| 25 |
struct S |
| 26 |
{ |
| 27 |
void operator=(const S&) = delete; |
| 28 |
}; |
| 29 |
|
| 30 |
S arr[1] = {}; |
| 31 |
auto a1 = std::to_array(arr); |
| 32 |
auto a2 = std::to_array(std::move(arr)); |
| 33 |
} |