Subject: [Boost-bugs] [Boost C++ Libraries] #7120: ambiguous overload of convert_construct in variant when one of variant's value types derives from variant
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-07-11 20:21:38
#7120: ambiguous overload of convert_construct in variant when one of variant's
value types derives from variant
------------------------------+---------------------------------------------
Reporter: jeffrey.hellrung | Owner: ebf
Type: Bugs | Status: new
Milestone: To Be Determined | Component: variant
Version: Boost 1.51.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
#include <boost/variant.hpp>
struct X
: boost::variant< int >
{ };
void main()
{
X x;
boost::variant<X> 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<T0_>::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<T0_>::convert_construct<int,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::detail::variant::void_>(const
boost::variant<int> &,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<T0_>::convert_construct<int,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::detail::variant::void_>(boost::variant<int>
&,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<T0_>::convert_construct<T>(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<T0_>::variant<X>(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<T>& 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?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7120> 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:10 UTC