MCPcopy Create free account
hub / github.com/changkun/modern-cpp-tutorial / learn_lambda_func_2

Function learn_lambda_func_2

code/3/3.1.cpp:23–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void learn_lambda_func_2() {
24 int value_2 = 1;
25 auto copy_value_2 = [&value_2] {
26 return value_2;
27 };
28 value_2 = 100;
29 auto stored_value_2 = copy_value_2();
30 // 这时, stored_value_2 == 100, value_1 == 100.
31 // 因为 copy_value_2 保存的是引用
32}
33
34int main() {
35 learn_lambda_func_1();

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected