23 lines · plain
1.. title:: clang-tidy - readability-use-anyofallof2 3readability-use-anyofallof4==========================5 6Finds range-based for loops that can be replaced by a call to7``std::any_of`` or ``std::all_of``. In C++20 mode, suggests8``std::ranges::any_of`` or ``std::ranges::all_of``.9 10Example:11 12.. code-block:: c++13 14 bool all_even(std::vector<int> V) {15 for (int I : V) {16 if (I % 2)17 return false;18 }19 return true;20 // Replace loop by21 // return std::ranges::all_of(V, [](int I) { return I % 2 == 0; });22 }23