Hi,
Can someone help me. I have defined a boost::variant with a visitor which issues an increment. The
visitor derived class below works fine for std::string and long long only
within the visitor, but as soon as I add a double, I get an ambiguous call
compile error (error below). I'm guessing when T within the prop_increment
class is an int, the compiler doesn't know whether to use the long long
version of the operator() or the double version. Does anyone know how I can
get around this when I apply the visitor? Interestingly enough, if I add an
int to the boost::variant template list the error goes away.
------ Compile Error ------
Error 44 error C2668:
'boost::detail::variant::make_initializer_node::apply::initializer_node::initialize'
: ambiguous call to overloaded function \boost\variant\variant.hpp 1273
-----------------------------
------ Visitor Class -----------
class prop_increment : public boost::static_visitor<> {
public:
template
void operator()( T &, const U & ) const
{
return;
}
template<typename T>
void operator()(T & lhs, const T& rhs) const {
lhs += rhs;
}
};
------------------------------------
boost::apply_visitor(prop_increment(),prop1,prop2);
---- Visitor Call -------------------
Thanks