Generally, I would use boost::mpl::for_each<>() to traverse a boost::mpl::vector, but this requires a functor with a template function declar
I liked (up-voted) the solution with pointer and own defined *_for_each function. Here is an alternative using type wrapper for T if the goal is to avoid object creation till it is needed.
template
struct Wrapper
{
typedef T type;
};
struct Functor
{
template void operator()(T t)
{
T::type obj(1);
T::type::static_fuc();
}
};
struct T1
{
T1(int a) : m_a(a) { }
int m_a;
static inline void static_fuc() { }
};
struct T2
{
T2(int a) : m_a(a) { }
int m_a;
static inline void static_fuc() { }
};
void fun()
{
namespace mpl=boost::mpl;
typedef mpl::vector,Wrapper > t_vec;
mpl::for_each(Functor());
}