AutosarC++17_10-A5.1.8ΒΆ
Lambda expressions should not be defined inside another lambda expression
Required inputs: IR
| Level | advisory |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Defining lambda expressions inside other lambda expressions reduces readability of the code.
Example
// $Id: A5-1-8.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
void Fn1() {
std::int16_t x = 0;
auto f1 = [&x]() {
auto f2 = []() {}; // Non-compliant
f2();
auto f4 = []() {}; // Non-compliant
f4();
}; // Non-compliant
f1();
}
void Fn2() {
auto f5 = []() {
// Implementation
}; // Compliant
f5();
}
See Also
- none
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
nested_lambda |
Lambda expressions should not be defined inside another lambda expression |
None |
False |
Options
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
This rule has no individual options.