Boost logo

Boost :

Subject: Re: [boost] [any] boost::get style accessors
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-04-29 13:26:50


----- Original Message -----
From: "Stefan" <mstefanro_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, April 29, 2010 6:50 PM
Subject: Re: [boost] [any] boost::get style accessors

>
> vicente.botet wrote:
>> ----- Original Message -----
>> From: "Christoph Heindl" <christoph.heindl_at_[hidden]>
>> To: <boost_at_[hidden]>
>> Sent: Thursday, April 29, 2010 5:50 PM
>> Subject: Re: [boost] [any] boost::get style accessors
>>
>>
>>
>> On Thu, Apr 29, 2010 at 1:10 PM, Stewart, Robert <Robert.Stewart_at_[hidden]> wrote:
>>> Christoph Heindl wrote:
>>>> On Wed, Apr 28, 2010 at 8:00 PM, Stewart, Robert
>>>> <Robert.Stewart_at_[hidden]> wrote:
>>>>
>>>>> At that point, I think they should be on par with any_cast
>>>>> rather than built on any_cast so that exceptions needn't be
>>>>> translated. Exception handling overhead is too costly to do
>>>>> it twice when it isn't necessary.
>>>> I agree. I don't see any added value by using bad_get, except all
>>>> boost:get accessors would throw bad_get exceptions.
>>> Perhaps you missed my point. I was suggesting that your gets be implemented at the same level of access as any_cast so no exception translation were needed. In other words, take code straight from any_cast and use it to implement get, provided bad_cast is deemed useful.
>>
>> Indeed I did. In boost 1.42 this corresponds to duplicating ~40 lines
>> of code to exchange the type of exception thrown. I'm not too keen of
>> doing this (not talking about the tests I would have to duplicate too)
>> :) Of course, code could be refactored to refer to a common set of
>> methods that take the exception to throw as templated argument, if
>> desired.
>>
>> _______________________________________________
>> +1 for refactoring.
>>
> It would make little sense to have a boost::get working with both
> Boost.Variant and Boost.Any transparently if it does not have a
> consistent behavior (i.e. the same way of signaling a problem). I don't
> think refactoring some code to make the behavior consistent will be
> problematic.
> Currently, boost::bad_get is deriving directly from std::exception
> whereas boost::bad_any_cast is deriving from std::bad_cast. It might
> make more sense to have both boost::bad_get and boost::bad_any_cast
> derive from a common exception class type, such as boost::bad_cast (or
> maybe have boost::bad_get derive from std::bad_cast)

I was talking only on refactoring the code on Boost.Any for the functions get and any_cast ;-)

Thinking a little bit more the introduction of boost::get<> in Boost.Any would result at the end on the deprecation of any_cast, isn't it? So the refactoring at the interface level will introduce constraints that sould be avoided.

Best,
Vicente

Vicente


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