[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #146553)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 1 14:49:07 PDT 2025
5chmidti wrote:
Thanks for testing this on your codebase so fast as well.
> I got some fixits that do not compile, e.g.:
>
> ```
> std::erase_if(numbers, [](int n) {
> return n % 2 == 0;
> });
> ```
>
> is changed into
>
> ```
> std::erase_if(numbers, [](int nconstexpr ) {
> return n % 2 == 0;
> });
> ```
I've tried to reproduce this but was unable to, could you please provide a small reproducer?
I've tried this, and it did not produce a diagnostic (using C++20):
```c++
#include <vector>
int main() {
std::vector<int> Numbers = {
0, 1, 2, 3, 4, 5, 6, 7,
};
const auto count = std::erase_if(Numbers, [](int N) { return N % 2 == 0; });
}
```
https://github.com/llvm/llvm-project/pull/146553
More information about the cfe-commits
mailing list