gcc/testsuite/g++.dg/cpp2a/constexpr-new6.C
raw| 1 | // P0784R7 |
| 2 | // { dg-do compile { target c++20 } } |
| 3 | |
| 4 | #include "construct_at.h" |
| 5 | |
| 6 | constexpr bool |
| 7 | foo () |
| 8 | { |
| 9 | std::allocator<int> a; |
| 10 | auto p = a.allocate (2); |
| 11 | std::construct_at (p, 1); |
| 12 | std::construct_at (p + 1, 2); |
| 13 | if (p[0] != 1 || p[1] != 2) |
| 14 | throw 1; |
| 15 | std::destroy_at (p); |
| 16 | std::destroy_at (p + 1); |
| 17 | a.deallocate (p, 2); |
| 18 | return true; |
| 19 | } |
| 20 | |
| 21 | static_assert (foo ()); |