[Boost-bugs] [Boost C++ Libraries] #10278: variant c2666, wrong constructor?

Subject: [Boost-bugs] [Boost C++ Libraries] #10278: variant c2666, wrong constructor?
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-30 06:17:33


#10278: variant c2666, wrong constructor?
------------------------------+---------------------
 Reporter: toby_toby_toby@… | Owner: ebf
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: variant
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------
 VC Express 2012, 11.0.61030.00 Update 4

 When I use variant<variant<A,B>,C> it's working, but with
 variant<deriver_from_other_variant,...> it's not. I think it's because of
 wrong variant constructor called (like we construct from variant<some
 types>, but not from just V1). Workaround for me is to use
 variant<class_that_has_V1_as_member_var,...>.



 {{{
 class V1 : public boost::variant<float,double>
         {
                 typedef boost::variant<float,double> base_type;
         public:
                 V1()
                 {
                 }
                 V1( const V1& other )
                         :base_type( static_cast<const base_type&>(other) )
                 {
                 }
                 V1& operator=( const V1& other )
                 {
                         static_cast<base_type&>(*this) = static_cast<const
 base_type&>(other);
                         return *this;
                 }
         };
         boost::variant<V1,std::string> v2 = V1(); // C2666
 }}}


 Full error text:

 {{{
 error C2666: 'boost::variant<T0_,T1>::convert_construct' : 3 overloads
 have similar conversions
 1> with
 1> [
 1> T0_=V1,
 1> T1=std::string
 1> ]
 1> f:\cpp\boost\boost/variant/variant.hpp(1724): could be 'void
 boost::variant<T0_,T1>::convert_construct<float,double,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>(boost::variant<float,double>
 &&,long)'
 1> with
 1> [
 1> T0_=V1,
 1> T1=std::string
 1> ]
 1> f:\cpp\boost\boost/variant/variant.hpp(1714): or 'void
 boost::variant<T0_,T1>::convert_construct<float,double,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost::detail::variant::void_>(const
 boost::variant<float,double> &,long)'
 1> with
 1> [
 1> T0_=V1,
 1> T1=std::string
 1> ]
 1> f:\cpp\boost\boost/variant/variant.hpp(1600): or 'void
 boost::variant<T0_,T1>::convert_construct<V1>(T
 &&,int,boost::mpl::false_)'
 1> with
 1> [
 1> T0_=V1,
 1> T1=std::string,
 1> T=V1
 1> ]
 1> while trying to match the argument list '(V1, long)'
 1> test.cpp(31) : see reference to function template
 instantiation 'boost::variant<T0_,T1>::variant<V1>(T &&,void *,void *)'
 being compiled
 1> with
 1> [
 1> T0_=V1,
 1> T1=std::string,
 1> T=V1
 1> ]
 1> test.cpp(31) : see reference to function template
 instantiation 'boost::variant<T0_,T1>::variant<V1>(T &&,void *,void *)'
 being compiled
 1> with
 1> [
 1> T0_=V1,
 1> T1=std::string,
 1> T=V1
 1> ]
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10278>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC