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?
}
Применяет ли IOC (неявно создание объекта) к My_alloc wrapping std :: malloc ?
Рассмотрим P0593 и следующий код: < /p> [code]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? } [/code] [b] Применяет ли IOC (неявно создание объекта) к My_alloc wrapping std :: malloc ? [/b]