Rule A5-1-3 (required, implementation, automated)

Parameter list (possibly empty) shall be included in every lambda expression.

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 [9]: 5.1.5 Include a (possibly empty) parameter list in every lambda expression