Boost logo

Boost Users :

From: dirk_griffioen (diddekio_at_[hidden])
Date: 2003-08-12 05:42:58


I would like to use a for_each with a class member function.

The for_each in myclass::do_print below does not compile. And I
simply cant figure it out.

I'm using vc7.1.

void print2(std::string s)
  cout << s << '\n';

class myclass
  void print(std::string s);
  void do_print();

void myclass::print(std::string s)
  cout << s << '\n';

void myclass::do_print()
  vector<std::string> v;
  for_each(v.begin(), v.end(),
           &myclass::print, _1));

nor will

for_each(v.begin(), v.end(), boost::bind(&myclass::print, _1));
for_each(v.begin(), v.end(), boost::bind(print, _1));


for_each(v.begin(), v.end(), boost::bind(print2, _1));

is ok

It seems natural to do, but I cant get it.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at