You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is effectively what you have to do to do constexpr vector-like things. Placement new is not yet constexpr (C++26) and you cannot change pointer types at compile time until C++26 too.
So you cannot just "new" a bunch of bytes then expect to use them.
#include<string>constexprvoidf()
{
std::allocator<std::string> allocator;
auto *ptr = allocator.allocate(10);
std::construct_at(ptr, "Hello a long string");
std::construct_at(ptr + 1, "World");
std::destroy_at(ptr);
std::destroy_at(ptr+1);
allocator.deallocate(ptr, 10);
}
intmain()
{
[] consteval { f(); }();
}
The text was updated successfully, but these errors were encountered:
This is effectively what you have to do to do constexpr vector-like things. Placement new is not yet constexpr (C++26) and you cannot change pointer types at compile time until C++26 too.
So you cannot just "new" a bunch of bytes then expect to use them.
The text was updated successfully, but these errors were encountered: