|
Boost : |
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-07-22 06:00:17
The Boost.Lambda library continues to delight and frustrate me! I have
this code sequence, which is intended to determine whether a predicate
is true for all objects pointed to by the second member of all of
vector of pairs,
#include <utility>
#include <vector>
#include <algorithm>
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
struct S
{
bool predOfS( );
};
int main( )
{
using namespace std;
using namespace boost :: lambda;
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!
- The error message reckons the last arg to find_if is placeholder<4>, not
placeholder<3>, why?
Or maybe there's completely different way to do this kind of thing?
Thanks, Rob.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk