11 June 2024

All About Calls

This is a terse but detailed description of function objects in C++ (any object for which the function call operator operator() is defined), including the different ways to pass them to functions and how each are implemented under the hood.

The Callables

The three main types of function objects are lambdas (anonymous function objects), std::function, and C-style function pointers.

Function Pointers

Exactly what they sound like: just a pointer to the address of a function. Note that &foo and foo are equivalent.

Lambdas

Lambdas are NOT std::functions.