Since C++17 it is possible to use a lambda expression in a constexpr
function.
In the related document Wording for constexpr lambda this code example is shown:
constexpr int AddEleven(int n) { return [n] { return n + 11; }(); }
Is this just a toy example to demonstrate the language feature, or is there an actual use case where this code has a different behaviour than the following code?
constexpr int AddEleven(int n) {
return n + 11;
}
What would be the benefit of using a lambda expression in this case?