F
Frederick Gotham
I see that the Standard provides "set_new_handler", but I don't see an
equivalent "get_new_handler" anywhere. Do we have to do something like the
following?
#include <new>
inline void (*GetCurrentNewHandler())()
{
struct Dummy { static void DummyFunc() {} };
void (*const p)() = std::set_new_handler(Dummy:ummyFunc);
std::set_new_handler(p);
return p;
}
inline void InvokeCurrentNewHandler()
{
GetCurrentNewHandler()();
}
I think GetCurrentNewHandler might no be thread-safe though, in the event
that "new" would be used in another thread in between the "set_new_handler"
calls.
equivalent "get_new_handler" anywhere. Do we have to do something like the
following?
#include <new>
inline void (*GetCurrentNewHandler())()
{
struct Dummy { static void DummyFunc() {} };
void (*const p)() = std::set_new_handler(Dummy:ummyFunc);
std::set_new_handler(p);
return p;
}
inline void InvokeCurrentNewHandler()
{
GetCurrentNewHandler()();
}
I think GetCurrentNewHandler might no be thread-safe though, in the event
that "new" would be used in another thread in between the "set_new_handler"
calls.