Conversation
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).
FranckRJ
approved these changes
Jun 6, 2020
Contributor
FranckRJ
left a comment
There was a problem hiding this comment.
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).
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 |
Contributor
|
Oh ok, seems logical, thanks ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.