Functions and Function Objects
Let's take a look at the first two types of callables in C++.
We'll cover the following...
We'll cover the following...
Functions
Functions are the simplest callables. They can have, apart from static variables, no state. Because the definition of a function is often widely separated from its use or even in a different translation unit, the compiler has fewer opportunities to optimize the resulting code.
The code above takes squares for each of the values in the given set by using std::for_each algorithm.
Function objects
At first, don’t call them functors. That’s a well-defined term from the category theory.
Function objects are objects ...