|
Boost Users : |
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2008-07-21 10:46:12
Using the code snippet below as an example,...
#include <vector>
#include <algorithm>
#include <functional>
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
#include <boost/function.hpp>
struct S { int methodOfS( ); };
int main( )
{
typedef std :: vector<S *> Vec;
using namespace boost :: lambda;
boost :: function<int( S * )> fn = bind( & S :: methodOfS, _1 );
Vec v;
Vec :: iterator match;
match = find_if( v.begin( ), v.end( ), bind( fn, _1 ) != fn( * v.begin( )
) ); // OK
match = find_if( v.begin( ), v.end( ), fn( _1 ) != fn( * v.begin( ) ) );
// Fail
}
I find the line marked 'OK' compiles, but not the line marked 'Fail'. Isn't
the
very point of Boost.Bind to enable this kind of syntax? Is there a better
way to write it than my 'Fail' line, but which will still compile?
Thanks, Rob.
-- ACCU - Professionalism in programming - http://www.accu.org
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