| 32 | } |
| 33 | |
| 34 | int main() { |
| 35 | learn_lambda_func_1(); |
| 36 | learn_lambda_func_2(); |
| 37 | |
| 38 | auto important = std::make_unique<int>(1); |
| 39 | auto add = [v1 = 1, v2 = std::move(important)](int x, int y) -> int { |
| 40 | return x+y+v1+(*v2); |
| 41 | }; |
| 42 | std::cout << add(3,4) << std::endl; |
| 43 | |
| 44 | // 泛型 lambda |
| 45 | auto generic = [](auto x, auto y) { |
| 46 | return x+y; |
| 47 | }; |
| 48 | |
| 49 | generic(1, 2); |
| 50 | generic(1.1, 2.2); |
| 51 | return 0; |
| 52 | } |
nothing calls this directly
no test coverage detected