Boost logo

Boost :

From: Gavin Lambert (boost_at_[hidden])
Date: 2021-03-22 06:48:43


On 22/03/2021 5:48 pm, Robert Ramey wrote:
> I have a really dumb question about this.  Consider the count_if
> example.  I understand how example works.  But I can't figure out where
> the parameter _1 gets filled in. So I think that the count_if example
> should be completed with a small bit of code which uses the newly
> count_if function.

The _1 parameter is filled in by std::count_if itself (in this case,
using each element of the passed iterators). That's the point of a
lambda, so I'm not quite sure what you're unclear on. This is not
creating a "count_if" function, if that's what you thought; it is a
complete example including both definition and usage.

Having said that, I do think the docs could benefit by having some
"compare and contrast" examples -- i.e. showing how each of those
examples would have been implemented using C++11 lambdas or std::bind
instead (and thus demonstrate the syntactic benefits of the library).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk