Issue 167375
Summary [clang-tidy] Make `readability-use-anyofallof` check suggest usage of 'std::none_of'
Labels enhancement, clang-tidy
Assignees
Reporter vbvictor
    Currently, we only diagnose suggestions with `std::all_of`, `std::any_of`.
I think we can add some heuristics to print to suggest for `std::none_of` too.
E.g. given this code:

```cpp
for (auto E : S1)
  if (S2.count(E) == 0)
 return false;
return true;
```

It's arguably better to write `none_of` than `any_of`:
```cpp
// we did't change predicate at all
return std::ranges::none_of(S1, [&S2](const auto& E) { return S2.count(E) == 0; });
// we changed predicate to '!='
return std::ranges::all_of(S1, [&S2](const auto& E) { return S2.count(E) != 0; });
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to