Skip to content

Implement LWG-3660 for iterator_traits::pointer - #2549

Merged
Stephan T. Lavavej (StephanTLavavej) merged 2 commits into
microsoft:mainfrom
CaseyCarter:lwg3660
Feb 12, 2022
Merged

Stephan T. Lavavej (StephanTLavavej) merged 2 commits into
microsoft:mainfrom
CaseyCarter:lwg3660

Conversation

@CaseyCarter

@CaseyCarter Casey Carter (CaseyCarter) commented Feb 8, 2022 •

Copy link
Copy Markdown
Contributor

LWG-3660 "iterator_traits::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::pointer` should conform to [iterator.traits]" requires a tweak to iterator_traits so it always agrees with `operator->()`.
@CaseyCarter Casey Carter (CaseyCarter) added the LWG Library Working Group issue label Feb 8, 2022
@CaseyCarter
Casey Carter (CaseyCarter) requested a review from a team as a code owner February 8, 2022 18:00
@CaseyCarter Casey Carter (CaseyCarter) linked an issue Feb 8, 2022 that may be closed by this pull request
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) changed the title Implement LWG-3660 Implement LWG-3660 for iterator_traits::pointer Feb 8, 2022
@StephanTLavavej

Copy link
Copy Markdown
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 thread stl/inc/iterator
Comment on lines +1045 to +1049
// clang-format off
template
requires _Has_member_arrow&> //
struct _Common_iterator_pointer_type<_Iter, _Se> {
// clang-format on

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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?

Comment thread stl/inc/iterator
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 6a478bf into microsoft:main Feb 12, 2022
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing this iterator_traits machinery! 🛠️ 🎉 😻

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_traits>::pointer is sometimes wrong

4 participants