Chapter 7. Higher Order and Compile-time Programming
A number of Standard Library algorithms take callable entities called function objects (function pointers, functors, and so on) as parameters. They call these function objects on individual elements of containers to compute some value or perform some action. Thus, a part of the runtime logic of the algorithm is encapsulated in a function or functor and supplied as an argument to the algorithm. A function may also return function objects instead of data values. The returned function object can be applied on a set of parameters and may in turn return either a value or another function object. This gives rise to higher order transforms. This style of programming involving passing and returning functions is called higher order programming.
C++ templates enable us to write type generic code. Using templates, it is possible to execute branching and recursive logic at compile time and conditionally include, exclude, and generate code...