Modify

Opened 3 years ago

Closed 11 months ago

#10278 closed Bugs (fixed)

variant c2666, wrong constructor?

Reported by: toby_toby_toby@… Owned by: Antony Polukhin
Milestone: Boost 1.62.0 Component: variant
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

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>          ]

Attachments (0)

Change History (2)

comment:1 Changed 16 months ago by Antony Polukhin

Milestone: To Be DeterminedBoost 1.62.0
Owner: changed from ebf to Antony Polukhin
Status: newassigned

Fixed in d23cdd35 develop, will be merged to master branch as soon as the tests will cycle.

comment:2 Changed 11 months ago by Antony Polukhin

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Antony Polukhin.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.