The question is not quite clear, but are you perhaps looking for this?
class test {
//...
struct my_visitor : public boost::static_visitor<> {
test &my_test;
my_visitor(test &arg) : my_test(arg) {}
void operator()( string s ) const { my_test.func3(s); }
void operator()( double d ) const { my_test.func4(d); }
//... for each supported type
};
//...
};
test::func1(Variant V) {
boost::apply_visitor(my_visitor(*this), V);
}
EDIT Added const
qualifiers to operator()
to allow using temporaries of my_visitor
in apply_visitor()
.