|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-07-21 12:38:36
AMDG
Robert Jones wrote:
> 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?
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
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