lambda表达式

[capture](params) -> return_type {
    body;
}

主要捕获方式为值捕获和引用捕获。
ex:

int factor = 3;
auto multiply = [factor](int x) { return x * factor; };
cout << multiply(10) << endl; // 输出 30

posted @ 2025-05-29 21:32  lyrrr  阅读(13)  评论(0)    收藏  举报