xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/readability/use-anyofallof.rst (revision 00e80fbfb9151a68e7383dcec7da69c867225e54)
1.. title:: clang-tidy - readability-use-anyofallof
2
3readability-use-anyofallof
4==========================
5
6Finds range-based for loops that can be replaced by a call to ``std::any_of`` or
7``std::all_of``. In C++20 mode, suggests ``std::ranges::any_of`` or
8``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 by
21    // return std::ranges::all_of(V, [](int I) { return I % 2 == 0; });
22  }
23