tidy - readability-use-anyofallof — Extra Clang Tools 22.0.0git documentation (original) (raw)
readability-use-anyofallof¶
Finds range-based for loops that can be replaced by a call tostd::any_of or std::all_of. In C++20 mode, suggestsstd::ranges::any_of or std::ranges::all_of.
Example:
bool all_even(std::vector V) { for (int I : V) { if (I % 2) return false; } return true; // Replace loop by // return std::ranges::all_of(V, [](int I) { return I % 2 == 0; }); }