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

<mdspan>: Check preconditions of mdspan::operator[] clarified by LWG-3974 #4214

Merged
merged 2 commits into from Nov 29, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

Closes #4166.

I believe the original implementation is conforming after LWG-3974, because the difference between index-cast and static_cast can't be observed without UB (precondition violation). This PR intends to improve precondition checking.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner November 22, 2023 15:56
@github-actions github-actions bot added this to Initial Review in Code Reviews Nov 22, 2023
@StephanTLavavej StephanTLavavej added LWG Library Working Group issue mdspan C++23 mdspan labels Nov 27, 2023
@StephanTLavavej StephanTLavavej self-assigned this Nov 27, 2023
Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

Just a static_assert message nit, which I'll apply.

I believe the original implementation is conforming after LWG-3974, because the difference between index-cast and static_cast can't be observed without UB (precondition violation).

That was my determination as well when LWG suggested changing the resolution to use index-cast.

stl/inc/mdspan Outdated Show resolved Hide resolved
Clarify `static_assert` message.
@CaseyCarter CaseyCarter moved this from Initial Review to Final Review in Code Reviews Nov 28, 2023
@StephanTLavavej StephanTLavavej removed their assignment Nov 28, 2023
@StephanTLavavej StephanTLavavej moved this from Final Review to Ready To Merge in Code Reviews Nov 28, 2023
@StephanTLavavej StephanTLavavej self-assigned this Nov 29, 2023
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit c9d52cd into microsoft:main Nov 29, 2023
35 checks passed
Code Reviews automation moved this from Ready To Merge to Done Nov 29, 2023
@StephanTLavavej
Copy link
Member

Thanks for improving mdspan and resolving this LWG issue! 🎉 🚀 😺

@frederick-vs-ja frederick-vs-ja deleted the lwg-3974 branch November 29, 2023 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue mdspan C++23 mdspan
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

LWG-3974 mdspan::operator[] should not copy OtherIndexTypes
3 participants