If a pointer is allocated with memory by the new operator and the allocation isn't successful, is it safe to set the pointer to nullptr in the catch block?
foo* var;
try {
var = new foo[size];
}
catch (std::bad_alloc& e) {
std::cout << "Error: " << e.what() << "\n";
var = nullptr;
}