-
-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False compilation failure with ranges #410
Comments
Just for posterity's sake: #include <ranges>
#include <concepts>
#include <vector>
using namespace std;
int main()
{
/*
auto x = std::views::drop(3) | std::views::take(1);
vector<int> vv{1,2,3,4};
auto rng = vv | std::views::take(3);
auto sz = std::ranges::size(rng);
*/
std::vector vec{1, 2, 3, 4, 5, 6};
auto v = vec | std::views::reverse | std::views::drop(2);
} I was trying to play around with the commented out stuff, but I simplified it to the smaller example below it and got the same "vector is not a range" type of error. |
Hello @samwhitlock, thanks for reporting this. What you're looking at isn't an issue in C++ Insights. It is that Clang and with that C++ Insights, by default uses libstdc++ on Linux (GCC STL). Now, libstdc++ is written for GCC but also supports Clang. However, in transition periods like now, it can be that libstdc++ and Clang are not 100% compatible. I don't know whether it is something in Clang that is missing or something in libstdc++. If you compile the example with Clang in compiler explorer it doesn't compile godbolt.org/z/3eGx8Wv5M. C++ Insights by default uses libstdc++ but has an option for using libc++ instead (where you select the desired standard). In the case of ranges switching the STL is no win as libc++ hasn't implemented ranges yet. While likely not satisfying, I hope it helps. Andreas |
Definitely! i hope clang gets this support soon, as some of this stuff about how views are constructed will be great to see in cppinsights, especially the "lazy pipe" stuff, e.g. (you can close this issue if you wish, imo) |
ranges::begin
on a vector, which is a bit perplexingThe text was updated successfully, but these errors were encountered: