I have a function which check the x of a RectList if it matches
certain value, it put the y in an int vector, like this.
class Rect{
int x;
int y;
};
typedef list RectList;
// this compiles:
void addKey(RectList& rectList, vector<int>& keys, int value) {
for (RectList::iterator itr = rectList.begin(); itr != rectList.end(); itr++) {
Rect* r = (*itr);
if (r->x == value) {
keys.push_back(r->y);
}
}
}
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) )));
}
error:
oid addDeviantKey(RectList&, std::vector&, int)':
../DeviantPatternMatcher.cpp:146: error: no matching function for call
to 'std::vector::push_back(const
boost::lambda::lambda_functor