AutosarC++17_10-A5.1.3ΒΆ
Parameter list (possibly empty) shall be included in every lambda expression
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
The lambda-declarator is optional in a lambda expression and results in a closure that can be called without any parameters.
To avoid any visual ambiguity with other C++ constructs, it is recommended to explicitly include (), even though it is not strictly required.
Example
// $Id: A5-1-3.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
void Fn() {
std::int32_t i = 0;
std::int32_t j = 0;
auto lambda1 = [&i, &j] { ++i, ++j; }; // Non-compliant
auto lambda2 = [&i, &j]() {
++i;
++j;
}; // Compliant
}
See Also
- HIC++ v4.0 [8]: 5.1.5 Include a (possibly empty) parameter list in every lambda expression
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
missing_parameters |
Include a (possibly empty) parameter list |
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.