Function Pointers and Lambdas
Lambdas
- Lambdas are short inline functions that are going to be used only once and thus do not need to be written as independent functions.
General Structure
[captures]<tparams>(params) specs {body}
[captures]
→ Interface to decide what variables are to be shared to the lambda’s body from the code scope.
tparams
→
params
→ Parameters to pass in the function. Similar to capture but you can pass constant values without definition here.
{body}
→ The body to write the the function implementation.
Captures
Function Pointers
- Function Pointers are a way to assign function to variables. It can be used to pass function as parameters to other functions.
Resources