30 Mar
2005
30 Mar
'05
3:30 a.m.
Can anyone explain why the class member functions need their address taken when used in a boost::lambda::bind inside the class? e.g. vector<int> v; MyClass theClass; for_each(v.begin(), v.end(), bind(MyClass::DoSomething, &theClass, _1)); //The above compiles fine, but. class MyClass { public: void DoSomething(const int& i) { . } void Go() { for_each(myInts.begin(), myInts.end(), /*--------------------->*/ bind(MyClass::DoSomething, this, _1)); } vector<int> myInts; }; The above code does not compile. The marked line needs to be: bind(&MyClass::DoSomething, this, _1)); Why? Thanks. - Sean