5 Mar
2006
5 Mar
'06
1:58 a.m.
Meryl Silverburgh wrote:
But when I try to replace the code using boost lambda, I can't get it to compile. can you please tell me what am I missing?
void addKey(RectList& rectList, vector<int>& keys, int value) {
for_each(rectList.begin(), rectList.end(), if_then( bind (&Rect::x, _1) == value, deviantKey.push_back( bind (&Rect::y, _1) )));
}
You're missing a bind. You need to bind the push_back call. for_each(rectList.begin(), rectList.end(), if_then( bind( &Rect::x, _1) == value, bind(&std::vector<int>::push_back, deviantKey, bind( &Rect::y, _1)))); Not tested. Sebastian Redl