Boost logo

Boost :

From: David Bergman (davidb_at_[hidden])
Date: 2002-08-14 14:27:17


True, true.

There are other places than a "catch" where copy-constructors are in
work. Anyhow, it is the copy-constructor that "slices"...

/David

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Peter Dimov
Sent: Wednesday, August 14, 2002 3:13 PM
To: boost_at_[hidden]
Subject: Re: [boost] std::exception

From: "Bill Seymour" <bill-at-the-office_at_[hidden]>
>
> What did surprise me is that, when I catch the exception
> in f() by either const or non-const reference, the exception
> still gets sliced. I added a catch(X) block after the
> catch(Y) in main() and the "abnormal program termination"
> became "Caught an X!\n", so slicing really does explain it.
>
> It seems to me that slicing when catching by reference
> is a bug in my implementation; but I can't cite anything
> in the Standard to support that. 8-(

Your implementation is correct. "throw x" throws a copy of x, not x
itself,
and a copy of

X const & x;

is a X. So it is "throw x" that slices, not "catch(X const & x)". :-)

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


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