Boost logo

Boost Users :

From: Bill McLean (bill_at_[hidden])
Date: 2008-08-11 23:39:07


 

I have spent a couple of hours trying to resolve the following error when
building our system. We have some code that has been compiling and working
with GCC with no issues. However building it with MS VC20005 SP1 creates the
following error. We are using boost 1.34.1:

 

Error 2 error C2666:
'boost::variant<T0_,T1,T2,T3,T4,T5,T6,T7>::convert_construct' : 2 overloads
have similar conversions
c:\projects\ardev\currentdev\externallibs\boost\boost\variant\variant.hpp
1342

 

I have searched the Boost list archives and found this post for boost
1.33.1:

 

http://lists.boost.org/Archives/boost/2006/03/102375.php

 

The author of this post Peter Schreegle did not receive a reply. He attached
the below code and build log. It appears that this an issue for variants
under visual studio 2005 SP1. Does anyone know if this is an issue for VS
2008? Is this issue for boost 1.35.0 being built by VS 2005 or VS 2008?

#include <boost/variant.hpp>

typedef boost::variant<char, int, double> numeric_type_variant;

class numeric_type
        : public numeric_type_variant
{
public:
        /// Default constructor.
        numeric_type() : numeric_type_variant() { }

        template <typename T>
        /// Converting constructor.
        numeric_type(T const& 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<T0_,T1,T2>::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<T0_,T1,T2>::convert_construct<char,int,double,boost::detail::

variant::void_,boost::detail::variant::void_,boost::detail::variant::void_,b

oost::detail::variant::void_,boost::detail::variant::void_,boost::detail::va

riant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boo

st::detail::variant::void_,boost::detail::variant::void_,boost::detail::vari

ant::void_,boost::detail::variant::void_,boost::detail::variant::void_,boost

::detail::variant::void_,boost::detail::variant::void_,boost::detail::varian

t::void_,boost::detail::variant::void_>(const boost::variant<T0_,T1,T2>
&,long)'
        with
        [
            T0_=char,
            T1=int,
            T2=double
        ]
        c:\_ngi\toolkits\boost_1_33_1\boost\variant\variant.hpp(1258): or
'void boost::variant<T0_,T1,T2>::convert_construct<const T>(T
&,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<T0_,T1,T2>::variant<T>(const T &)' 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<T0_,T1,T2>::assign<T>(const T &)' 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<T0_,T1,T2>
&boost::variant<T0_,T1,T2>::operator =<numeric_type>(const T &)' 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 ==========

 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net