Issue |
125740
|
Summary |
Invalid fixit from modernize-use-ranges for binary std::transform
|
Labels |
new issue
|
Assignees |
|
Reporter |
chrchr-github
|
~~~c++
#include <vector>
#include <algorithm>
#include <ranges>
#include <iostream>
int main() {
std::vector<int> a = { 1, 2, 3 }, b = { 3, 2, 1 };
std::ranges::transform(a, b.begin(), a.begin(), [](auto x, auto y) { return x + y; });
//std::ranges::transform(a, b, a.begin(), [](auto x, auto y) { return x + y; }); // valid
for (auto i : a)
std::cout << i << ' ';
}
~~~
~~~
<source>:8:5: warning: use a ranges version of this algorithm [modernize-use-ranges]
1 | #include <vector>
2 | #include <algorithm>
3 | #include <ranges>
4 | #include <iostream>
5 |
6 | int main() {
7 | std::vector<int> a = { 1, 2, 3 }, b = { 3, 2, 1 };
8 | std::transform(a.begin(), a.end(), b.begin(), a.begin(), [](auto x, auto y) { return x + y; });
| ^~~~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~
| std::ranges::transform a
~~~
https://godbolt.org/z/PE1YhYYh8
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs