Код: Выделить всё
struct A { std::string s; };
static_assert(std::is_implicit_lifetime_v); // true!
// std::malloc is explicitly BLESSED by the C++23 standard.
// But my_alloc is not.
void* my_alloc() {
return std::malloc(sizeof(A));
}
int main() {
auto p1 = static_cast(std::malloc(sizeof(A)));
// OK. An object of A is implicitly created and begins its lifetime.
auto p2 = static_cast(my_alloc());
// OK? Is there an object of A implicitly created here?
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... -stdmalloc