Boost logo

Boost Users :

Subject: [Boost-users] [mpl] bind help sought
From: Manfred Doudar (manfred.doudar_at_[hidden])
Date: 2010-02-22 15:19:51


Hi,

I need to be explicit about a function call, but unsure quite how to
make it work, cut down example follows:

struct M
{
  static
  void foo() { ... }
};

struct R
{
  static
  void foo() { ... }
};

struct Func
{
  typedef void result_type;

  template <typename T, typename U>
  result_type
  operator()(U& u) const
  {
      T::foo(); // call on either M or R

      // do something with 'u'
  }
};

int main(int argc, char** argv)
{
  using namespace boost::mpl;

  typedef vector<M, R> vec;

  Func f;
  Object instance;
  for_each<vec>(boost::bind(&Func::operator()<XXX, Object>,
                            boost::ref(f),
                            instance)
               );

  return 0;
}

Question is, what goes in at XXX above?

I was thinking something along the lines of:

   boost::mpl::bind<boost::mpl::_1>

..but well, that doesn't work.

All help appreciated.

Cheers,

-- 
Manfred

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