|
Boost Users : |
Subject: Re: [Boost-users] Boost.Variant broke in 1.54?
From: Edward Diener (eldiener_at_[hidden])
Date: 2013-08-04 15:35:15
On 8/4/2013 8:57 AM, gast128 wrote:
> Dear all,
>
> I get a compilation error with Boost.Variant (which compiles fine on
> previous releases) with vstudio 2010 when a function returns a const
> Boost.Variant, e.g.:
>
> typedef boost::variant<int, double> Variant;
>
> const Variant GetVar()
> {
> return Variant();
> }
>
>
> void TestVariantDnc()
> {
> const Variant var = GetVar();
> }
>
> This gives error C2666 ('boost::variant<T0_,T1>::convert_construct' : 3
> overloads have similar conversions').
>
> Shall a file a ticket or do I something wrong?
Returning a 'const X' is meaningless. Just return 'X' instead. The same
goes for passing something as 'const X'. When you pass or return by
value you get a copy of the object being passed so it means nothing to
say that the object is 'const'.
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