Skip to content

Don't move from contained value of optional<const T> - #2460

Merged
Stephan T. Lavavej (StephanTLavavej) merged 3 commits into
microsoft:mainfrom
CaseyCarter:optional_const
Mar 4, 2022
Merged

Stephan T. Lavavej (StephanTLavavej) merged 3 commits into
microsoft:mainfrom
CaseyCarter:optional_const

Conversation

@CaseyCarter

Copy link
Copy Markdown
Contributor

...unless T supports it, of course.

Fixes #2458
Fixes DevCom-1628644 / VSO-1458298 / AB#1458298

...unless `T` supports it, of course.

Fixes microsoft#2458
Fixes DevCom-1628644 / VSO-1458298 / AB#1458298
@CaseyCarter Casey Carter (CaseyCarter) added the bug Something isn't working label Jan 6, 2022
@CaseyCarter
Casey Carter (CaseyCarter) requested a review from a team as a code owner January 6, 2022 19:30

@fsb4000 Igor Zhukov (fsb4000) left a comment

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.

Note to self: that issue was because _Value defined as remove_const_t<_Ty> _Value;
So we always could move _Value. and now with operator* we are taking into account the const of _Ty.

Comment thread tests/std/tests/P0220R1_optional/test.cpp Outdated
@StephanTLavavej

This comment was marked as resolved.

@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 598cdfa into microsoft:main Mar 4, 2022
@CaseyCarter
Casey Carter (CaseyCarter) deleted the optional_const branch March 4, 2022 22:23
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing this moving bug! 🐛 🐞 😸

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<optional>: std::optional move constructor moves a const object

5 participants