Boost logo

Boost :

From: jarvi (jarvi_at_[hidden])
Date: 2005-06-06 13:00:50


On Jun 6, 2005, at 12:32 PM, Rafal Dabrowa wrote:

> Suppose I have the following structure:
>
> struct xy { int x, y; };
>
> and the following vector:
>
> vector<xy> v(10);
>
> I want to use lambda library for find an item in the table.
> Let's say, with x member value equal to 10.
> Something like this doesn't work:
>
> pos = find_if(v.begin(), v.end(), _1.x == 10);
>
> How the above line should be written ?
>

Operator . is not overloadable, so the above cannot work.
The lambda expression should be:

bind(&xy::x, _1) == 10

   Jaakko


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk