任何人都可以提供分配失败的示例。即我只是想调用我引用的new_handler函数:
#include <iostream>
#include <new>
void *p = operator new(0);
void foo()
{
std::cout << "something" << "\n";
}
int main()
{
std::set_new_handler(foo);
std::get_new_handler()(); //Ok, but I want that the function invoke as memory allocation fail handler
}