Exactly, warning about all std::endl might be too much (used in a lot of places, and it might be intended), while two consecutive flushes is most likely unintended.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In a project I noticed following pattern
And a similar patterns one with flush, like "std::endl << std::flush"
Fortunately, it was easy to write a custom check
I would prefer if cppcheck would do a similar verification by itself; what are the criteria for adding a new check in cppcheck?
Note that this pattern is not an error per se, but it hurts performance, as in general "\n" will already do a flush, and std::endl always flushes.
clang -tidy detects any
endl
usage asperformance-avoid-endl
.I am not against it. your suggestion sounds less aggressive than clang-tidy 👍
The main criteria is that it will be low noise. And well if you warn about redundant flushes that does not sound very noisy to me.
Exactly, warning about all std::endl might be too much (used in a lot of places, and it might be intended), while two consecutive flushes is most likely unintended.