Boost logo

Boost :

Subject: Re: [boost] [Exception] Why is there no non-const version of get_error_info?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-08-20 20:48:54

On Wed, Aug 19, 2009 at 3:49 PM, Steven Watanabe<watanabesj_at_[hidden]> wrote:
> Emil Dotchevski wrote:
>> On Wed, Aug 19, 2009 at 5:14 AM, Adam Badura<abadura_at_[hidden]> 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.

Boost list run by bdawes at, gregod at, cpdaniel at, john at