June 2025
Intermediate to advanced
1093 pages
33h 24m
English
Even more than <numeric>, the functions in <functional> are there to complement other parts of the standard library. You will rarely include <functional> alone. And if you want to solve a “simple” task with <algorithm> or a container, it's worth taking a look at <functional>, where there might already be a solution for it.
If you want to sum up all elements of a container, for example, use accumulate from <numeric>. But if you want to use * instead of +, you can
either write a lambda [](auto a, auto b) { return a*b; };
or use multiplies from <functional>, which does exactly that.
And so it is with many things from <functional>.
I categorize the things offered in <functional> (more ...
Read now
Unlock full access