From: Daryle Walker (darylew_at_[hidden])
Date: 2002-07-31 13:26:56
on 7/30/02 10:12 AM, David Abrahams at dave_at_[hidden] wrote:
> I just noticed this in the docs for i/o state savers:
> 1.. When a new success state is activated for exception watching, an
> exception is thrown if that state is already active. This could mean that
> the destructor of this class template may throw.
> What steps does the class take to prevent termination during exception
> unwinding? If none, I think it's unacceptable. If it does take steps, they
> need to be spelled out; the statement above is too alarming by itself.
It takes no precautions. You have to take the risk. I'm not sure that
anything can, or should, be done.
There is a standard function to check if we are already handling an
exception, but I heard that many don't think it's useful. Worse, the
function is not implemented on some compilers (like mine!).
> Also, I wonder about the potential for throwing an exception when stream
> state is restored in general. If an i/o operation fails, and the saver
> resets the stream state while it is being destroyed, can that operation
> fail? If it fails, what happens?
I think the stream state (re)setting is just bit-twiddling, so that should
be fail-free. If an exception is generated, then that exception will throw,
or another (e.g. std::bad_alloc) if that I/O exception object fails to be
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk