can I use the memory of a dynamic array of integers with placement new
?
int* p = new int[10]{};
std::string* pstr = new(p)std::string("Hi there");
std::cout << *pstr << std::endl;
pstr->~std::string();
delete[] p;
The code works fine but is it safe to do so? Thank you!