Boost logo

Boost :

Subject: Re: [boost] [any] boost::get style accessors
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-04-30 07:13:55


----- Original Message -----
From: "Stewart, Robert" <Robert.Stewart_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, April 30, 2010 12:57 PM
Subject: Re: [boost] [any] boost::get style accessors

>
> Christoph Heindl wrote:
>> On Thu, Apr 29, 2010 at 7:26 PM, vicente.botet
>> <vicente.botet_at_[hidden]> wrote:
>> >
>> > 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?
>>
>> If boost any_cast<> has equivalent sematics to boost::get<> and
>> boost::get<> is the perferred generic way (which I think it is) to
>> retrieve values then +1 for the deprecation.
>
> +1 for having a common approach to extracting such values. boost::get<> is consistent with tuples, not just variant, so I think it is the right interface. any_cast is, of course, highly specific.

Well, tuples don't have the type as parameter, but the index or a tag.
In addition tuples don't need exceptions as the access is checked at compile time. Even if the name is the same and the intentions is quite close, although different, the interface is clearly different, so there is no advange other than using the same name, i.e. no possibility for generic code using both.

> I don't know that any_cast need be deprecated, though, because I haven't looked into the details. If it works differently in any way, can be more efficient, or is otherwise a closer fit to boost::any, then there's no reason to deprecate or remove it. Those working strictly with boost::any could prefer it. If those things are not true, then I think deprecation is in order.
>
>> > So the refactoring at the interface level will introduce
>> > constraints that sould be avoided.
>>
>> Could you please elaborate on your thoughts?
>
> I suppose that Vicente meant that this would be a breaking change that he'd like to avoid, which is understandable. I don't think maintaining both interfaces and explaining why both exist is onerous, so that might be the best course.

What a meant is that if any_cast is deprecated it is not worth to try to assocaite bag_get and bad_any_cast in any way.

best,
Vicente


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