Hello all,
I have the following:
template<typename T>
void f() { /* ... */ }
typedef boost::mpl::vector my_vec;
I'm looking for a way to call f<T>() for all types T in my_vec. I initially
hoped that either an mpl algorithm or fusion::for_each might be able to
accomplish this for me, but after reading through their docs this doesn't appear
to be the case.
Am I correct in this conclusion? If not, I'd really appreciate someone giving me
a quick pointer as to what I need to do.
Currently I'm using the specialization/static-recursion trick. Something like:
template
struct helper
{
static void call_f()
{
using namespace boost::mpl;
f< at::type >();
helper::call_f(); // recurse
}
};
template
struct helper
{
static void call_f() { } // end recursion
};
void call_f_with_each_type()
{
enum { num_types = size::type::value };
helper::call_f();
}
It works fine, but I'm wondering if there's a more succinct and readable way.
Kind regards,
Edd