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

Update range concepts #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update range concepts #93

wants to merge 2 commits into from

Conversation

tcbrindle
Copy link
Owner

No description provided.

empty_view was accidentally privately rather than publicly inhertiting from view_interface. This has been wrong for basically the entire time that NanoRange has ever existed, and nobody (including me) has noticed until now. Hmmm.

While we've got the hood up, let's also remove the begin() and end() friends since they're no longer needed, and change size() to return a size_t since everybody loves unsigned types apparently.
If you're going to write a blog post about something, you should probably make sure your own library implements it correctly, right?

This commit removes the heuristic that assumes something is a view if begin() and cbegin() return the same type, which is rather wonderful and means we no longer have to do the ugly special-casing of lots of standard library types (other than string_view, which I can live with).
Copy link
Contributor

@FranckRJ FranckRJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just have one question, why std::initializer_list is not a view ? It seems to follow all the requirements, even if it's not explicitly said in the standard that it has a constant-time copy / move construction / assignment (at least i didn't see this requirement with a quick look at it).

@tcbrindle
Copy link
Owner Author

As far as I know, it's to avoid things like

// Assuming enable_view<initializer_list<T>>
auto v = std::initializer_list<std::string>{"a", "b", "c"}
        | views::transform([](const auto& s) { return s.size(); });

and then trying to use v after the temporary strings have been destroyed.

@FranckRJ
Copy link
Contributor

FranckRJ commented Jun 6, 2020

Oh ok, seems logical, thanks !

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

Successfully merging this pull request may close these issues.

None yet

2 participants