Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ANSI/ISO |
C++ only | z/OS V1R2 |
#include <exception>
bool uncaught_exception(void);
The uncaught_exception() function returns true only if a thrown exception is currently being processed.
When uncaught_exception() is true, throwing an exception can result in a call of terminate().
uncaught_exception() returns true after completing evaluation of a throw expression and before completing initialization of the exception declaration in the matching handler or calling unexpected() as a result of the throw expression.
Otherwise, uncaught_exception() returns false.
#include <exception>
#include <iostream.h>
using namespace std;
class X
{
public:
~X ();
};
X::~X()
{
if (uncaught_exception ())
printf (" X::~X called during stack unwind\n");
else
printf (" X::~X called normally\n");
}
int main()
{
X x1;
try
{
X x2;
throw 1;
}
catch (...) { /*...*/ }
return 0;
}
// under a Standard-conforming implementation, this program yields
// X::~X called during stack unwind
// X::~X called normally