Lambda 表达式:捕获、参数与生命周期 | C++

本章覆盖:lambda syntax;capture list;capture by value;capture by reference;init capture;mutable lambda;generic lambda;return type deduction;捕获 this;C++20 `[=, this]` 等版本差异认知;reference capture 的生命周期风险;callback 异步执行时尤其警惕悬空捕获。

本章知识点

  • lambda syntax
  • capture list
  • capture by value
  • capture by reference
  • init capture
  • mutable lambda
  • generic lambda
  • return type deduction
  • 捕获 this
  • C++20 [=, this] 等版本差异认知
  • reference capture 的生命周期风险
  • callback 异步执行时尤其警惕悬空捕获