| 1 |
// PR c++/115754 |
| 2 |
// { dg-do compile { target c++26 } } |
| 3 |
|
| 4 |
namespace std |
| 5 |
{ |
| 6 |
using size_t = decltype (sizeof 0); |
| 7 |
|
| 8 |
template <typename T> |
| 9 |
struct allocator |
| 10 |
{ |
| 11 |
constexpr allocator () noexcept {} |
| 12 |
|
| 13 |
constexpr T *allocate (size_t n) |
| 14 |
{ return static_cast<T *> (::operator new (n * sizeof(T))); } |
| 15 |
|
| 16 |
constexpr void |
| 17 |
deallocate (T *p, size_t n) |
| 18 |
{ ::operator delete (p); } |
| 19 |
}; |
| 20 |
} |
| 21 |
|
| 22 |
constexpr void * |
| 23 |
operator new (std::size_t, void *p) noexcept |
| 24 |
{ return p; } |
| 25 |
|
| 26 |
constexpr bool |
| 27 |
foo () |
| 28 |
{ |
| 29 |
std::allocator<int> a; |
| 30 |
auto b = a.allocate (1); |
| 31 |
::new (b) int (); |
| 32 |
a.deallocate (b, 1); |
| 33 |
return true; |
| 34 |
} |
| 35 |
|
| 36 |
constexpr bool a = foo (); |