-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implement P3349R1 Converting Contiguous Iterators To Pointers #5683
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
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
tests/std/tests/P3349R1_contiguous_iterators_to_pointers/env.lst
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
tests/std/tests/P3349R1_contiguous_iterators_to_pointers/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P3349R1_contiguous_iterators_to_pointers/test.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/P3349R1_contiguous_iterators_to_pointers/test.cpp
Outdated
Show resolved
Hide resolved
|
Thanks again, pushed another round of changes. Hopefully I didn't mess anything up this time! 😹 |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Thanks for implementing this C++26 feature, and congratulations on your first microsoft/STL commit! 😻 🎉 🎂 This feature will ship in the MSVC Build Tools 14.51 in a future VS 2026 update (I don't know exactly which one yet). |
This PR audits and updates all calls to
to_address(or_To_address) to ensure that bothto_address(i)andto_address(i + (s - i))(which should be equivalent to the standard-mandatedto_address(i + ranges::distance(i, s))) are evaluated before using the pointer converted from the iterator. Fixes #5295.Additional Notes:
For algorithms accepting an iterator pair
[i, s), this change evaluates onlyto_address(s)instead ofto_address(i + (s - i)).While the proposal specifies converting
[i, s)to[to_address(i), to_address(i + (s - i)))(implying at least oneoperator+invocation before conversion), iterator requirements guarantee thati + (s - i)must be equal tos, and functions likeranges::advancealso do not actually "advance" the iterator in this case.Based on the proposal’s intent, this should not affect iterator validation: if
i + (s - i)is invalid, thensis already invalid and should have been checked before the library call.This could be revised later if necessary.
The constructors of
string_viewandspan, as well as the implementation ofviews::counted, are intentionally unchanged, as the standard explicitly specifies their behavior ([string.view.cons]/9, 13, [span.cons]/6, 11, 19, [range.counted]/2.1). This may be worth submitting as a potential defect.Added some previously missing
static_casts to pass the tests.