Hello,
I'm having difficulty compiling the following code fragment using the Intel 9.1 C++ compiler.
This little program mimics part of our application and the way we make use of the boost::variant class template. The build log follows at the end. The program itself is totally meaningless, but it just demonstrates a problem in either the compiler or in boost.
The strange thing is that this program compiles nicely without any problem using the gcc 3.3.1 compiler on Linux.
I appreciate any help.
TIA
Paul
#include <map>
#include <string>
#include
using namespace std;
template <typename IntT=int>
class A
{
public:
A() : m_i(0) { }
A(const IntT& i) : m_i(i) { }
private:
IntT m_i;
};
template
class B
{
public:
B() : m_pi(0) { }
B(const string& s, const IntT& i) : m_pi(new IntT(i)) { }
~B() { delete m_pi; }
private:
StringT m_s;
IntT* m_pi;
};
typedef A<> a_t;
typedef B<string> b_t;
typedef boost::variant > Integer;
typedef Integer* IntegerPtr;
template
class numeric_type
: public boost::variant
{
public:
typedef boost::variant numeric_type_variant;
/// Default constructor.
numeric_type() : numeric_type_variant() { }
numeric_type(const CharT& ch) : numeric_type_variant(ch)
{
}
numeric_type(IntT* pInt) : numeric_type_variant(pInt)
{
}
numeric_type(const DoubleT& d) : numeric_type_variant(d)
{
}
/* 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;
double bc;
// set up map with variant integers
map mapInteger;
mapInteger.insert(make_pair("a", a_t(0)));
mapInteger.insert(make_pair("b", b_t("b", 1)));
numeric_type b(ba);
numeric_type c(&mapInteger["b"]);
numeric_type d(bc);
return 0;
}
------ Build started: Project: VariantProblemDemo, Configuration: Debug Win32 ------
Compiling...
VariantProblemDemo.cpp
C:\Mijn Documenten\Backup\Projects\Work\3rdParty\boost\boost\variant\variant.hpp(1273) : error C2668: 'boost::detail::variant::make_initializer_node::apply::initializer_node::initialize' : ambiguous call to overloaded function
with
[
BaseIndexPair=boost::mpl::aux::iter_fold_impl<2,boost::mpl::begin>::recursive_enabled_types>::type,boost::mpl::end>::recursive_enabled_types>::type,boost::mpl::pair>,boost::mpl::lambdaboost::detail::variant::make_initializer_node>::type>::state1,
Iterator=boost::mpl::aux::iter_fold_impl<2,boost::mpl::begin>::recursive_enabled_types>::type,boost::mpl::end>::recursive_enabled_types>::type,boost::mpl::pair>,boost::mpl::lambdaboost::detail::variant::make_initializer_node>::type>::iter1
]
C:\Mijn Documenten\Backup\Projects\Work\3rdParty\boost\boost\variant\detail\initializer.hpp(89): could be 'int boost::detail::variant::make_initializer_node::apply::initializer_node::initialize(void *,boost::detail::variant::make_initializer_node::apply::initializer_node::param_T)'
with
[
BaseIndexPair=boost::mpl::aux::iter_fold_impl<2,boost::mpl::begin>::recursive_enabled_types>::type,boost::mpl::end>::recursive_enabled_types>::type,boost::mpl::pair>,boost::mpl::lambdaboost::detail::variant::make_initializer_node>::type>::state1,
Iterator=boost::mpl::aux::iter_fold_impl<2,boost::mpl::begin>::recursive_enabled_types>::type,boost::mpl::end>::recursive_enabled_types>::type,boost::mpl::pair>,boost::mpl::lambdaboost::detail::variant::make_initializer_node>::type>::iter1
]
C:\Mijn Documenten\Backup\Projects\Work\3rdParty\boost\boost\variant\detail\initializer.hpp(89): or 'int boost::detail::variant::make_initializer_node::apply::initializer_node::initialize(void *,boost::detail::variant::make_initializer_node::apply::initializer_node::param_T)'
with
[
BaseIndexPair=boost::mpl::aux::iter_fold_impl<2,boost::mpl::begin>::recursive_enabled_types>::type,boost::mpl::end>::recursive_enabled_types>::type,boost::mpl::pair>,boost::mpl::lambdaboost::detail::variant::make_initializer_node>::type>::state0,
Iterator=boost::mpl::aux::iter_fold_impl<2,boost::mpl::begin>::recursive_enabled_types>::type,boost::mpl::end>::recursive_enabled_types>::type,boost::mpl::pair>,boost::mpl::lambdaboost::detail::variant::make_initializer_node>::type>::iter0
]
while trying to match the argument list '(void *, const int)'
C:\Mijn Documenten\Backup\Projects\Work\3rdParty\boost\boost\variant\variant.hpp(1342) : see reference to function template instantiation 'void boost::variant::convert_construct<const T>(const T &,int,boost::mpl::false_)' being compiled
with
[
T0_=a_t,
T1=boost::recursive_wrapper,
T=int
]
VariantProblemDemo.cpp(62) : see reference to function template instantiation 'boost::variant::variant<int>(const T &)' being compiled
with
[
T0_=a_t,
T1=boost::recursive_wrapper,
T=int
]
VariantProblemDemo - 1 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped