Boost C++ Libraries: Ticket #10278: variant c2666, wrong constructor? https://svn.boost.org/trac10/ticket/10278 <p> VC Express 2012, 11.0.61030.00 Update 4 </p> <p> When I use variant&lt;variant&lt;A,B&gt;,C&gt; it's working, but with variant&lt;deriver_from_other_variant,...&gt; it's not. I think it's because of wrong variant constructor called (like we construct from variant&lt;some types&gt;, but not from just V1). Workaround for me is to use variant&lt;class_that_has_V1_as_member_var,...&gt;. </p> <pre class="wiki">class V1 : public boost::variant&lt;float,double&gt; { typedef boost::variant&lt;float,double&gt; base_type; public: V1() { } V1( const V1&amp; other ) :base_type( static_cast&lt;const base_type&amp;&gt;(other) ) { } V1&amp; operator=( const V1&amp; other ) { static_cast&lt;base_type&amp;&gt;(*this) = static_cast&lt;const base_type&amp;&gt;(other); return *this; } }; boost::variant&lt;V1,std::string&gt; v2 = V1(); // C2666 </pre><p> Full error text: </p> <pre class="wiki">error C2666: 'boost::variant&lt;T0_,T1&gt;::convert_construct' : 3 overloads have similar conversions 1&gt; with 1&gt; [ 1&gt; T0_=V1, 1&gt; T1=std::string 1&gt; ] 1&gt; f:\cpp\boost\boost/variant/variant.hpp(1724): could be 'void boost::variant&lt;T0_,T1&gt;::convert_construct&lt;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_&gt;(boost::variant&lt;float,double&gt; &amp;&amp;,long)' 1&gt; with 1&gt; [ 1&gt; T0_=V1, 1&gt; T1=std::string 1&gt; ] 1&gt; f:\cpp\boost\boost/variant/variant.hpp(1714): or 'void boost::variant&lt;T0_,T1&gt;::convert_construct&lt;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_&gt;(const boost::variant&lt;float,double&gt; &amp;,long)' 1&gt; with 1&gt; [ 1&gt; T0_=V1, 1&gt; T1=std::string 1&gt; ] 1&gt; f:\cpp\boost\boost/variant/variant.hpp(1600): or 'void boost::variant&lt;T0_,T1&gt;::convert_construct&lt;V1&gt;(T &amp;&amp;,int,boost::mpl::false_)' 1&gt; with 1&gt; [ 1&gt; T0_=V1, 1&gt; T1=std::string, 1&gt; T=V1 1&gt; ] 1&gt; while trying to match the argument list '(V1, long)' 1&gt; test.cpp(31) : see reference to function template instantiation 'boost::variant&lt;T0_,T1&gt;::variant&lt;V1&gt;(T &amp;&amp;,void *,void *)' being compiled 1&gt; with 1&gt; [ 1&gt; T0_=V1, 1&gt; T1=std::string, 1&gt; T=V1 1&gt; ] 1&gt; test.cpp(31) : see reference to function template instantiation 'boost::variant&lt;T0_,T1&gt;::variant&lt;V1&gt;(T &amp;&amp;,void *,void *)' being compiled 1&gt; with 1&gt; [ 1&gt; T0_=V1, 1&gt; T1=std::string, 1&gt; T=V1 1&gt; ] </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10278 Trac 1.4.3 Antony Polukhin Mon, 30 May 2016 17:15:14 GMT owner, status, milestone changed https://svn.boost.org/trac10/ticket/10278#comment:1 https://svn.boost.org/trac10/ticket/10278#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">ebf</span> to <span class="trac-author">Antony Polukhin</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.62.0</span> </li> </ul> <p> Fixed in <a class="ext-link" href="https://github.com/boostorg/variant/commit/d23cdd3502b452231c6c6bc2f2d4298ca24b5650"><span class="icon">​</span>d23cdd35 develop</a>, will be merged to master branch as soon as the tests will cycle. </p> Ticket Antony Polukhin Sat, 29 Oct 2016 18:09:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/10278#comment:2 https://svn.boost.org/trac10/ticket/10278#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket