[range.iter.ops], default_sentinel, and unreachable_sentinel#329
[range.iter.ops], default_sentinel, and unreachable_sentinel#329CaseyCarter merged 1 commit intomicrosoft:masterfrom
Conversation
Implements iterator primitive operations `std::ranges::advance`, `std::ranges::next`, `std::ranges::prev`, and `std::ranges::distance`; as well as `std::default_sentinel` and `std::unreachable_sentinel`. This change reworks the STL's iterator unwrapping machinery to enable unwrapping of C++20 move-only single-pass iterators (and `if constepxr`s all the things). Consequently, `_Iter_ref_t`, `_Iter_value_t`, and `_Iter_diff_t` resolve to `iter_reference_t`, `iter_value_t`, and `iter_difference_t` (respectively) in `__cpp_lib_concepts` (soon to be C++20) mode. This change necessitates some fixes to `unique_copy` and `_Fill_memset_is_safe` which both assume that `_Iter_value_t<T>` is well-formed for any iterator `T`. (`iter_value_t<T>` does not have that property: it is only well-formed when `readable<T>`.) I notably haven't unified `default_sentinel_t` with `_Default_sentinel` out of an abundance of paranoia. Our `move_iterator` is comparable with `_Default_sentinel`, which is not the case for `std::default_sentinel`. Drive-by: * This change `if constexpr`-izes `unique_copy`.
miscco
left a comment
There was a problem hiding this comment.
I am just a dude so this feels like my two year old telling me how to speak properly but meh...
There is a lot of __foo to _Foo noise going on here. I would suggest to put that into a different commit, so that it doesnt drain too much mental capacity. Also there are quite some places where this was not applied.
The same goes for _STD to _RANGES and the _Unwrapped_t<Foo> to _Unwrapped_t<const Foo&> If they are separated into their own commit they are easily verifiable and do not drain so much energy form the real changes
Ironically enough, all three of these cases were expansions of the PR requested during internal review. Hopefully we'll have the test infrastructure online soon so this silly dual-review process can stop and we can properly work completely out of GitHub. |
|
@CaseyCarter Sorry for the noise. The internal conventions are quite hard to get. Thanks for the explanations |
Description
Implements iterator primitive operations
std::ranges::advance,std::ranges::next,std::ranges::prev, andstd::ranges::distance; as well asstd::default_sentinelandstd::unreachable_sentinel.This change reworks the STL's iterator unwrapping machinery to enable unwrapping of C++20 move-only single-pass iterators (and
if constepxrs all the things). Consequently,_Iter_ref_t,_Iter_value_t, and_Iter_diff_tresolve toiter_reference_t,iter_value_t, anditer_difference_t(respectively) in__cpp_lib_concepts(soon to be C++20) mode. This change necessitates some fixes tounique_copyand_Fill_memset_is_safewhich both assume that_Iter_value_t<T>is well-formed for any iteratorT. (iter_value_t<T>does not have that property: it is only well-formed whenreadable<T>.)I notably haven't unified
default_sentinel_twith_Default_sentinelout of an abundance of paranoia. Ourmove_iteratoris comparable with_Default_sentinel, which is not the case forstd::default_sentinel.Drive-by:
if constexpr-izesunique_copy.[This is a replay of Microsoft-internal PR MSVC-PR-214209.]
Checklist
Be sure you've read README.md and understand the scope of this repo.
If you're unsure about a box, leave it unchecked. A maintainer will help you.
_Uglyas perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
verified by an STL maintainer before automated testing is enabled on GitHub,
leave this unchecked for initial submission).
members, adding virtual functions, changing whether a type is an aggregate
or trivially copyable, etc.).
the C++ Working Draft (including any cited standards), other WG21 papers
(excluding reference implementations outside of proposed standard wording),
and LWG issues as reference material. If they were derived from a project
that's already listed in NOTICE.txt, that's fine, but please mention it.
If they were derived from any other project (including Boost and libc++,
which are not yet listed in NOTICE.txt), you must mention it here,
so we can determine whether the license is compatible and what else needs
to be done.