
On Wed, Aug 19, 2009 at 3:49 PM, Steven Watanabe<watanabesj@gmail.com> wrote:
AMDG
Emil Dotchevski wrote:
On Wed, Aug 19, 2009 at 5:14 AM, Adam Badura<abadura@o2.pl> wrote:
This is especially strange because operator << can be used to add data to a const exception object so I don't see reason for not being able to get modifiable data back (at least from non-const exception object).
Adding error info is supported for const exceptions because it isn't stored in the exception object itself, it's stored in a separate object the exception points to. This arrangement can't be just an implementation detail because the copy constructor is required to be nothrow.
The other reason is to support the throw foo() << my_Info() syntax.
If operator<< is defined as a member function then it can take an rvalue exception and still be non-const.
Oh, bummer. We can't do this in boost::exception because it is critical for the exception type (the "this" if op<< were a member) to be deduced implicitly. More precisely, the return type of op<< has to be the same as the type of the object on the left of op<<, so we don't get a slice in an expression like throw foo()<<my_info(). Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode