Hello,
I'm rather stucked in using lambda expressions for a presumably simple task.
Suppose I have objects with a member function
bool is_empty() const;
stored in a vector: I want to count the number of objects for which their
member functions returns false, which is simple, but not elegant to achieve
by
size_t sum = 0;
for( Foo::const_iterator it = vec.begin(); it != vec.end(); ++it )
if ( it->is_empty() == false ) sum++;
I want to exchange this for a lambda expression, and came up with the
following after some thinking.
for_each( begin(), end(), if_then( !(_1 ->* &GridCell::is_empty)(),
var(sum)++ ) );
This is still wrong and leads to two error messages:
error C2784: 'const
boost::lambda::lambda_functor