From: Jeremy Day (jeremy.day_at_[hidden])
Date: 2006-07-21 08:35:18
On 7/21/06, Sebastian Redl <sebastian.redl_at_[hidden]> wrote:
> The use case for uncaught_exception() is quite simple: it allows
> destructors to take different actions depending on whether they're
> destructed due to stack unwind or a different reason.
> I've used it in a thin wrapper around jpeglib: there you have to wrap
> the encoding/decoding process in matching function calls, with different
> end calls depending on whether an error occurred.
I have done a similar thing with uncaught_exception(). I have a wrapper
around a series of database primatives, and my destructor looks something
//Something went wrong, and I cannot be certain that the state of the
transaction is valid.
//My wrapper is being destroyed on account of leaving scope, so the
transaction is good.
This type of activity is very common in any object involved in the oddly
name Resource Acquisition is Initialization (RAII) idiom.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk