Here is an example of c++20 code which compiles in g++-12 and newest msvc and fails to compile in clang++-14.
// Type your code here, or load an example.
#include <iostream>
#include <ranges>
#include <initializer_list>
void printOdd(std::initializer_list<int> numbers) {
for (auto num : numbers | std::views::filter([](int i) { return 0 == i % 2; })) {
std::cout << num << ' ';
}
std::cout << std::endl;
}
int main() {
printOdd({4, 5, 6, 8, 8, 2});
return 0;
}
Is it a bug of clang? If it is a bug, what is the best way to write code in the way as in the example (use range adaptors with std::initializer_list)?