Boost logo

Boost Users :

Subject: [Boost-users] Using mpl to instantiate template function
From: Richard Hazlewood (boost_at_[hidden])
Date: 2009-07-02 07:16:42


Is there a type-only based way (e.g. with fold) of getting mpl to stamp out
template functions for a collection of types?

For example, this appears to work using mpl::for_each

  template <typename T>
  void Foo();

  typedef mpl::vector<t1, t2, t3> Types;

  struct StampOut
  {
    template <typename T
    void operator()(const T *) const
    {
        Foo<T>();
    }
  };

  void dummy_()
  {
    mpl::for_each<Types>(Types, add_pointer<mpl::_1> >(StampOut());
  }

However, it requires the "dummy_" function to force instantiation. Is there
an alternative trick?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net