Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-14 14:07:36


From: "David Bergman" <davidb_at_[hidden]>
> Peter,
>
> One "subtle" note, though. You are aware that what you threw in 'f' was
> actually the original object?

Yes, that was the point I was trying to make; I said in the original post
that

> > >Well, I am not a compiler writer, but it seems to me that to
> implement
> > >"throw;" and "catch", the compiler already needs a way to copy the
> > >exception, complete with its original type. :-)

The exception is sliced by the catch() clause, but the original is retained
and rethrown.

> The copy-constructor of X *does* indeed
> slice (they always do, them copy-constructors ;-). If you want to see
> the effect of this X object being passed up, and caught as an Y, change
> the code to:

This calls abort() as expected. :-) You can't catch X as Y.

Either way, it seems clear to me that a compiler can transport an exception
in the way we need (since it can generate clone() and throw_this()
functions - or an equivalent - for the correct type at the throw point, even
if the actual exception handling implementation doesn't already require
them.)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk