MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / main

Function main

07.19-lambdaInitCapture0/main.cpp:4–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2// SPDX-License-Identifier: MIT
3
4int main()
5{
6 int x = 3;
7
8 auto l1 = [y = x // #A A lambda init-capture, creating a new variable y with x as value
9 ] { return y; };
10
11 auto l2 = [x = x // #B The same name of x inside the lambda
12 ] { return x; }; // #C Here x refers to the x of the lambda, not to the x in the outer scope
13}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected