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

Implement LWG-3660 for iterator_traits<common_iterator>::pointer #2549

Merged
merged 2 commits into from
Feb 12, 2022

Conversation

CaseyCarter
Copy link
Member

@CaseyCarter CaseyCarter commented Feb 8, 2022

LWG-3660 "iterator_traits<common_iterator>::pointer should conform to [iterator.traits]" requires a tweak to iterator_traits so it always agrees with operator->().

Also removes comments for LWG-3601 and LWG-3616 which have been voted into the Standard, see #2527.

LWG-3660 "`iterator_traits<common_iterator>::pointer` should conform to [iterator.traits]" requires a tweak to iterator_traits so it always agrees with `operator->()`.
@CaseyCarter CaseyCarter added the LWG Library Working Group issue label Feb 8, 2022
@CaseyCarter CaseyCarter requested a review from a team as a code owner February 8, 2022 18:00
@CaseyCarter CaseyCarter mentioned this pull request Feb 8, 2022
20 tasks
@StephanTLavavej StephanTLavavej changed the title Implement LWG-3660 Implement LWG-3660 for iterator_traits<common_iterator>::pointer Feb 8, 2022
@StephanTLavavej
Copy link
Member

I've updated this PR's title (and #2548) to include a short explanation of what the LWG issue is about. (They don't need to copy the issue's name exactly, just have a quick summary.) This makes it easier to read the Code Reviews project (so we don't have to memorize what each LWG issue number means) and will make it easier to read the commit history when this is eventually merged.

Comment on lines +1045 to +1049
// clang-format off
template <class _Iter, class _Se>
requires _Has_member_arrow<const common_iterator<_Iter, _Se>&> //
struct _Common_iterator_pointer_type<_Iter, _Se> {
// clang-format on
Copy link
Member

Choose a reason for hiding this comment

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

Mega-nitpick, not worth resetting testing, no change requested: The empty comment // (to force wrapping) is unnecessary in a clang-format off region.

Copy link
Member Author

Choose a reason for hiding this comment

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

Argh.

@frederick-vs-ja
Copy link
Contributor

Is it intended that common_iterator::operator-> sometimes returns the iterator by reference?
The Range-v3 and Ranges TS versions of common_iterator::operator-> always return by value. But since respecifying common_iterator with variant, it has been made returning by reference in some circumstance.

@StephanTLavavej StephanTLavavej self-assigned this Feb 11, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo. Requesting or pushing changes is totally fine, but please notify me if that happens.

@CaseyCarter
Copy link
Member Author

Is it intended that common_iterator::operator-> sometimes returns the iterator by reference? The Range-v3 and Ranges TS versions of common_iterator::operator-> always return by value. But since respecifying common_iterator with variant, it has been made returning by reference in some circumstance.

It's certainly what the spec requires, although looking at it today I'm not sure why. Maybe I wanted to avoid unnecessary iterator copies? Maybe I thought doing so would make it easier to support move-only iterators?

stl/inc/iterator Show resolved Hide resolved
@StephanTLavavej StephanTLavavej merged commit 6a478bf into microsoft:main Feb 12, 2022
@StephanTLavavej
Copy link
Member

Thanks for fixing this iterator_traits machinery! 🛠️ 🎉 😻

@CaseyCarter CaseyCarter deleted the lwg3660 branch February 12, 2022 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<iterator>: iterator_traits<common_iterator<I, S>>::pointer is sometimes wrong
4 participants
  翻译: