[lambda] Exploring bind syntax.
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 Vec;
using namespace boost :: lambda;
boost :: function
AMDG Robert Jones wrote:
int main( ) { typedef std :: vector
Vec; using namespace boost :: lambda;boost :: function
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?
You're talking about boost::lambda::bind, not boost::bind. They are not the same thing.
Is there a better way to write it than my 'Fail' line, but which will still compile?
You need to use the 'OK' line. boost::function doesn't know about boost::lambda::bind. In Christ, Steven Watanabe
participants (2)
-
Robert Jones
-
Steven Watanabe