
Hi, I've the following code: ---8<--- #include <boost/variant.hpp> #include <iostream> #include <string> struct available : public boost::static_visitor<bool> { template <typename T, typename U> bool operator()( const T&, const U& ) const { return false; // cannot compare different types } template <typename T> bool operator()( const T& lhs, const T& rhs ) const { static const std::string NA( "NA" ); return lhs != NA; //??? } }; using namespace boost; using namespace std; int main() { variant< double, std::string > R; variant< double, std::string > L; R = 3.14; L = "NA"; cout << R << endl; cout << L << endl; bool r = boost::apply_visitor(available(), R ); cout << ( r ? "true" : "false" ) << endl; bool l = boost::apply_visitor(available(), L ); cout << ( l ? "true" : "false" ) << endl; } --->8--- which does not compile. Anyway, from a data parser I get a double or a "NA" (not available) string. This test shall handle both cases. To process using the double I have to check if it available (than use defaults). Unfortunately, the static_visitor<bool> needs two arguments. How can I get the syntax (or simpler) as used in the example? Thanks Olaf