By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

Invoke New Handler

P: n/a

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::DummyFunc);

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.

--

Frederick Gotham
Nov 6 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.