|
Boost Users : |
From: Sean DeNigris (lotusone_at_[hidden])
Date: 2005-03-29 22:30:43
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
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