Skip to content

Implement LWG-3737 take_view::sentinel should provide operator- - #3320

Merged
Stephan T. Lavavej (StephanTLavavej) merged 5 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-3737
Jan 12, 2023
Merged

Stephan T. Lavavej (StephanTLavavej) merged 5 commits into
microsoft:mainfrom
frederick-vs-ja:lwg-3737

Conversation

@frederick-vs-ja

Copy link
Copy Markdown
Contributor

Fixes #3223.

(counted_iterator<counted_iterator<T>> seems a bit messy. Should I add a prettier test case?)

@frederick-vs-ja
A. Jiang (frederick-vs-ja) requested a review from a team as a code owner January 1, 2023 16:49
@CaseyCarter Casey Carter (CaseyCarter) added LWG Library Working Group issue ranges C++20/23 ranges labels Jan 2, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just some style nits.

Comment thread tests/std/tests/P0896R4_views_take/test.cpp
Comment thread tests/std/tests/P0896R4_views_take/test.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, although the utility of this LWG issue seems suspect to me lol (given that it only triggers when disable_sized_range<R> && sized_sentinel_for<S, I>)

@CaseyCarter

Copy link
Copy Markdown
Contributor

LGTM, although the utility of this LWG issue seems suspect to me lol (given that it only triggers when disable_sized_range<R> && sized_sentinel_for<S, I>)

More precisely, it's !sized_range<R> && sized_sentinel_for<sentinel_t<R>, iterator_t<R>>. Since ranges::size is smart enough to call begin and end an return the difference, this boils down to covering single-pass (not forward) ranges with sized_sentinel_for. IIRC I pointed this out to LWG and suggested closing as NAD, but LWG was convinced that it was worth doing "just in case" since the cost is a couple of small if constexpr branches.

Comment thread stl/inc/ranges Outdated
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks! Really appreciate the test case, especially when it's non-trivial to set up like this one.

Casey Carter (@CaseyCarter) nicole mazzuca (@strega-nil-ms) I pushed changes after you approved, to defend against min macroization.

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit c20a26b into microsoft:main Jan 12, 2023
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for taking the STL to the next level of conformance! 📊 🎉 😹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LWG Library Working Group issue ranges C++20/23 ranges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LWG-3737 take_view::sentinel should provide operator-

4 participants