new-handler函数调用

时间:2014-07-20 18:33:29

标签: c++ new-operator

任何人都可以提供分配失败的示例。即我只是想调用我引用的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
}

0 个答案:

没有答案