id summary reporter owner description type status milestone component version severity resolution keywords cc 7120 ambiguous overload of convert_construct in variant when one of variant's value types derives from variant jeffrey.hellrung Antony Polukhin "#include struct X : boost::variant< int > { }; void main() { X x; boost::variant y(x); } yields (MSVC9) 1>------ Build started: Project: scratch, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>c:\users\jeffrey\boost_1_49_0\boost\variant\variant.hpp(1405) : error C2666: 'boost::variant::convert_construct' : 3 overloads have similar conversions 1> with 1> [ 1> T0_=X 1> ] 1> c:\users\jeffrey\boost_1_49_0\boost\variant\variant.hpp(1384): could be 'void boost::variant::convert_construct(const boost::variant &,long)' 1> with 1> [ 1> T0_=X 1> ] 1> c:\users\jeffrey\boost_1_49_0\boost\variant\variant.hpp(1375): or 'void boost::variant::convert_construct(boost::variant &,long)' 1> with 1> [ 1> T0_=X 1> ] 1> c:\users\jeffrey\boost_1_49_0\boost\variant\variant.hpp(1315): or 'void boost::variant::convert_construct(T &,int,boost::mpl::false_)' 1> with 1> [ 1> T0_=X, 1> T=X 1> ] 1> while trying to match the argument list '(X, long)' 1> c:\users\jeffrey\scratch\main.cpp(10) : see reference to function template instantiation 'boost::variant::variant(T &)' being compiled 1> with 1> [ 1> T0_=X, 1> T=X 1> ] Basically, the problem appears to be the call to convert_construct(operand, 1L) // operand is of type X which cannot disambiguate between the overloads (simplified) void convert_construct([const] boost::variant& operand, long); void convert_construct(T& operand, int); The former requires a derived->base conversion in the first argument, while the latter requires a long->int conversion in the second argument. Perhaps the dispatching among the convert_construct overloads should be more sophisticated?" Bugs closed Boost 1.64.0 variant Boost 1.51.0 Problem fixed