Boost C++ Libraries: Ticket #592: ambiguous overloads in boost::variant source code https://svn.boost.org/trac10/ticket/592 <pre class="wiki">I cannot figure out, why the following little program does not compile. It simply typedefs a variant of a specific bounded type set and then derives a class from this type. I've tried to compile it with VC 2005. It does not compile because of ambiguous overloads within the boost::variant source. It would be very helpful if somebody could shed light on the issue. Best regards Peter PS: I intended to post this to the boost developers list, but I was unable to log onto the list today. ************************************************************* #include &lt;boost/variant.hpp&gt; typedef boost::variant&lt;char, int, double&gt; numeric_type_variant; class numeric_type : public numeric_type_variant { public: /// Default constructor. numeric_type() : numeric_type_variant() { } template &lt;typename T&gt; /// Converting constructor. numeric_type(T const&amp; t) : numeric_type_variant(t) { } // some more code }; int main(int argc, char* argv[]) { char ba; int bb; double bc; numeric_type a; numeric_type b(ba); numeric_type c(bb); numeric_type d(bc); a = ba; a = bb; a = bc; return 0; } ************************************************************* This is the build log: ------ Build started: Project: test_variant, Configuration: Debug Win32 ------ Compiling... test_variant.cpp c:\_ngi\toolkits\boost_1_33_1\boost\variant\variant.hpp(1342) : error C2666: 'boost::variant&lt;T0_,T1,T2&gt;::convert_construct' : 2 overloads have similar conversions with [ T0_=char, T1=int, T2=double ] c:\_ngi\toolkits\boost_1_33_1\boost\variant\variant.hpp(1327): could be 'void boost::variant&lt;T0_,T1,T2&gt;::convert_construct&lt;char,int,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_&gt;(const boost::variant&lt;T0_,T1,T2&gt; &amp;,long)' with [ T0_=char, T1=int, T2=double ] c:\_ngi\toolkits\boost_1_33_1\boost\variant\variant.hpp(1258): or 'void boost::variant&lt;T0_,T1,T2&gt;::convert_construct&lt;const T&gt;(T &amp;,int,boost::mpl::false_)' with [ T0_=char, T1=int, T2=double, T=numeric_type ] while trying to match the argument list '(const numeric_type, long)' c:\_ngi\toolkits\boost_1_33_1\boost\variant\variant.hpp(1580) : see reference to function template instantiation 'boost::variant&lt;T0_,T1,T2&gt;::variant&lt;T&gt;(const T &amp;)' being compiled with [ T0_=char, T1=int, T2=double, T=numeric_type ] c:\_ngi\toolkits\boost_1_33_1\boost\variant\variant.hpp(1590) : see reference to function template instantiation 'void boost::variant&lt;T0_,T1,T2&gt;::assign&lt;T&gt;(const T &amp;)' being compiled with [ T0_=char, T1=int, T2=double, T=numeric_type ] c:\_schrott\test_variant\test_variant\test_variant.cpp(36) : see reference to function template instantiation 'boost::variant&lt;T0_,T1,T2&gt; &amp;boost::variant&lt;T0_,T1,T2&gt;::operator =&lt;numeric_type&gt;(const T &amp;)' being compiled with [ T0_=char, T1=int, T2=double, T=numeric_type ] Build log was saved at "file://c:\_schrott\test_variant\test_variant\Debug\BuildLog.htm" test_variant - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/592 Trac 1.4.3 Steven Watanabe Mon, 18 Dec 2006 20:31:15 GMT <link>https://svn.boost.org/trac10/ticket/592#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/592#comment:1</guid> <description> <pre class="wiki">Logged In: YES user_id=1671606 Originator: NO This is an MSVC bug. You need to add: numeric_type(const numeric_type&amp; other) : numeric_type_variant(static_cast&lt;const numeric_type_variant&amp;&gt;(other)) {} numeric_type&amp; operator=(const numeric_type&amp; other) { *static_cast&lt;numeric_type_variant*&gt;(this) = static_cast&lt;const numeric_type_variant&amp;&gt;(other); return(*this); } MSVC incorrectly generates: numeric_type(const numeric_type&amp; other) : numeric_type_variant(other) {} numeric_type&amp; operator=(const numeric_type&amp; other) { *static_cast&lt;numeric_type_variant*&gt;(this) = other; return(*this); } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>ebf</dc:creator> <pubDate>Wed, 03 Jan 2007 02:06:05 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/592#comment:2 https://svn.boost.org/trac10/ticket/592#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> </ul> Ticket