Lambdas are a concise way of creating anonymous functions - when those functions are themselves concise. However, the use of lambdas for sizable functions can make the code difficult to read. More importantly, following variable capture in lambdas can be difficult, potentially leading to dangling pointers. Therefore lambdas should be avoided.


== Noncompliant Code Example

----
int main() {
  auto func = [] () { std::cout << "Hello world" << std::endl; };
  func();
}
----


== Compliant Solution

----
void func () {
  std::cout << "Hello world" << std::endl;
}

int main() {
  func();
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
