Lambdas in an Unevaluated Context and Stateless Lambdas
Explore more about lambdas in C++20.
We'll cover the following...
Admittedly, the title of this lesson contains two terms that may be new to you: unevaluated context and stateless lambda. Let me start with unevaluated context.
Unevaluated context
The following code snippet has a function declaration and a function definition.
int add1(int, int); // declaration
int add2(int a, int b) { return a + b; } // definition
Function add1
is declared, while add2
is defined. This means, if you use add1
in an evaluated context, for example, by invoking it, you get a link-time error. The key observation is that you can use add1
in ...