$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (dave_at_[hidden])
Date: 2006-08-20 22:59:13
Edd Dawson <edd_at_[hidden]> writes:
> Hello all,
>
> I have the following:
>
>      template<typename T>
>      void f() { /* ... */ }
>
>      typedef boost::mpl::vector<int, long, double> 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.
  struct call_f
  {
     template <class Wrapper>
     void operator()(Wrapper)
     {
         f<typename Wrapper::type>();
     }
  };
  mpl::for_each<my_vec, mpl::identity<_> >(call_f());
HTH,
-- Dave Abrahams Boost Consulting www.boost-consulting.com