Closed
Description
Affected rules
A13-5-2
Description
The A13-5-2
(cpp/autosar/user-defined-conversion-operators-not-defined-explicit
) rule triggers on lambda with empty captures.
Example
int ref_value{0};
int other_value{0};
// ok
auto dummy_lambda = [&ref_value]() noexcept -> void { ref_value = 42; };
dummy_lambda();
// ok
auto my_lambda_1 = [&ref_value](int param) noexcept -> void {
for (int i{0}; i < param; ++i) {
++ref_value;
}
};
my_lambda_1(other_value);
// error: user-defined-conversion-operators-not-defined-explicit
auto my_lambda_2 = [](int param) noexcept -> void {
for (int i{0}; i < param; ++i) {
//
}
};
my_lambda_2(other_value);
// ok
auto my_lambda_3 = [&ref_value](int param) noexcept -> void { ref_value = param; };
my_lambda_3(other_value);