Boost logo

Boost Users :

From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2006-03-04 16:04:14


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<Rect*> 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, std::allocator<int> >&, int)':
../DeviantPatternMatcher.cpp:146: error: no matching function for call
to 'std::vector<int, std::allocator<int> >::push_back(const
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::ac


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