== Why is this an issue?

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

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


=== Compliant solution

[source,cpp]
----
void func () {
  std::cout << "Hello world" << std::endl;
}

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


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Remove this lambda


'''
== Comments And Links
(visible only on this page)

=== on 28 Nov 2018, 19:59:46 Loïc Joly wrote:
Removing broken link, replacing it by new one.


This rule actually goes against what is said in the link (and does not make much sense). We should replace it by a set of rule about safe usage of lambdas.


Rules currently in this set: RSPEC-5019

Other rules should follow, when the set is done, we should deprecate this rule.

endif::env-github,rspecator-view[]
