Skip to content
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

Closed
samwhitlock opened this issue Jul 27, 2021 · 3 comments
Closed

False compilation failure with ranges #410

samwhitlock opened this issue Jul 27, 2021 · 3 comments

Comments

@samwhitlock
Copy link

@samwhitlock
Copy link
Author

samwhitlock commented Jul 27, 2021

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.

@andreasfertig
Copy link
Owner

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

@samwhitlock
Copy link
Author

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. auto x = std::views::drop(3) | std::views::take(1);. Thank you!

(you can close this issue if you wish, imo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants