I have the following program:
based on the (somewhat vague) description at this link, I'm expecting the destructor to display the message "Destroyed while handling an exception." Unfortunately, this does not seem to be the behavior I'm observing. it always says "Normal destruction."
std::exception_ptr ePtr = std::current_exception();
if (ePtr) std::cout << "Destroyed while handling an exception." << std::endl;
else std::cout << "Normal destruction." << std::endl;
catch (std::exception& ex)
std::cout << "Exception caught: " << ex.what() << std::endl;
am I interpreting the description of that function incorrectly, or is it behaving incorrectly? the gcc C++11 standard library status page doesn't even seem to have an entry for std::current_exception(). I want to have some code only run if the object is destroyed normally, but not if it was destroyed during the stack unwinding process of exception handling.
Fedora 15 x86_64
Linux kernel 2.6.38