|
Boost : |
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-07-22 07:28:42
Robert Jones wrote:
> typedef pair<int, S *> Pair;
> vector<Pair> pairs;
> bool trueForAll = ( find_if( _1, _2, _3 ) == _2 )(
> pairs.begin( ),
> pairs.end( ),
> ! bind( & S :: predOfS, bind( & Pair :: second, _1 ) ) );
> }
>
> The last line gives me compile errors.
>
> Two things:
> - I think I need to specicy the template parameters to find_if, but I'm not
> sure quite what they are!
Why are you even doing this?
find_if(pairs.begin(), pairs.end(), your_lambda_expression) is sufficient.
Otherwise, it is more practical to use a lazy function. Phoenix is
better for that, and it actually already provides lazy versions of
standard algorithms.
> - The error message reckons the last arg to find_if is placeholder<4>, not
> placeholder<3>, why?
Because _1 is placeholder<0>.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk