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).