Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-04-17 13:43:23

williamkempf_at_[hidden] wrote:
> If an exception is thrown the postcondition is almost gauranteed to
> fail. As for single entry/single exit functions... they're needed
> for checking postconditions, not for checking invariants. However,
> it would be nice if some mechanism could be devised that would allow
> postconditions to work regardless of the number of exit points.

It seems to me that you want to find out in your "postcondition
checking destructor" whether it was invoked because an exception was
thrown (and stack unwinding is happening) or because the scope
(function) was exited by normal means (i.e. return).

The C++ standard provides the function std::uncaught_exception()
which is true if your destructor is called during stack unwinding
and false otherwise. See section 18.6.4 in the C++ standard.

Note that this feature is said not to work reliably on some

Jens Maurer

Boost list run by bdawes at, gregod at, cpdaniel at, john at