Boost logo

Boost Users :

Subject: Re: [Boost-users] [Any] inconsistent return types of any_cast overloads
From: Arne Vogel (avogel_at_[hidden])
Date: 2013-12-04 04:58:34


On 03.12.2013 00:01, Krzysztof Czainski wrote:
> 2013/12/2 Antony Polukhin <antoshkka_at_[hidden]
> <mailto:antoshkka_at_[hidden]>>
>
> You are absolutely right: ValueType&& any_cast(any&&) was not a
> good idea and it may break code that accepts result by const
> reference.
> Making it ValueType any_cast(any&&) would be more correct.
>
> I'll fix that as soon as the migration to the GIT will be finished.
>
> Great thanks for finding, investigating and reporting this issue!
>
> Created ticket #9462 : https://svn.boost.org/trac/boost/ticket/9462
>

Thanks a lot!
>
>
> That said, what do you gain by doing:
> const auto& vec = boost::any_cast<std::vector<int>>(makeVec());
> instead of
> const auto vec = boost::any_cast<std::vector<int>>(makeVec());
> ?
>
> Regards,
> Kris

In C++11 with a moveable type, probably not much. I don't quite remember
why I wrote the code like this - it could have been out of habit since
in C++98 using a reference may save a copy, though I guess an optimizing
compiler had already been allowed to elide it.

Regards,
Arne



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net