The following code violates the MISRA C++ rule 0-1-4:
for (auto &a : b) {
... // The variable a is used only in the for condition.
}
Rule: A project shall not contain non-volatile POD variables having only one use. Variable 'a' is used only once, that is, during initialization.
What I tried:
for (const auto &a : b) {
... // The variable a is used only in the for condition.
}
But that was not the solution.
Does anyone have an idea how I can fix it?