Chapter 10. The bind Function Template

One Ring to bring them all and in the darkness bind them.

The Fellowship of the RingJ.R.R. TOLKIEN

Suppose that you have a pair of pointers, first and last, defining a sequence of integer values, and you need to know how many elements in the sequence have a value that is greater than or equal to 10. You can do this with the standard algorithm count_if and a predicate that returns true when called with a value that is greater than or equal to 10. The standard library doesn’t have that predicate, but it has less, which takes two arguments and returns true if the first argument is less than the second. If you had a way to tell count_if to always use 10 as the first argument to the less predicate, you’d have ...

Get The C++ Standard Library Extensions A Tutorial and Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.