If I understood your question correctly, you could just provide two overloads of the call operator, one which accepts instantiations of boost::tuple
and would call boost::fusion::for_each()
on that tuple, and another fallback one that would accept any kind of argument, and perform concrete operations on "leaf" types:
class A
{
public:
template<typename T>
void operator()(T& t) const
{
// Do something
}
template<typename... Ts>
void operator ()(boost::tuple<Ts...>& t) const
{
// Recurse
boost::fusion::for_each(t, A());
}
};
In the above example I am using C++11's variadic templates, so you will need a C++11-compliant compiler for that to work (and don't forget to specify the flag -std=c++11
or -std=c++0x
in the command line).