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-3918 std::uninitialized_move/_n and guaranteed copy elision #5135

Merged
merged 8 commits into from
Dec 5, 2024

Conversation

frederick-vs-ja
Copy link
Contributor

Also implements guaranteed copy elision in std::uninitialized_copy/_n, which has been implicitly required since C++17 without DR.

Corresponding ranges algorithms might also need to perform guaranteed copy elision, but that fix wouldn't affect well-formedness (for, IIUC, it would merely reduce moving when initializing constructor arguments). Perhaps we can do that in another PR.

Fixes #5113.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner November 25, 2024 12:55
@CaseyCarter CaseyCarter added the LWG Library Working Group issue label Nov 25, 2024
@CaseyCarter CaseyCarter removed their assignment Nov 26, 2024
@StephanTLavavej StephanTLavavej self-assigned this Nov 26, 2024
@StephanTLavavej
Copy link
Member

Thanks! I pushed significant changes to the test, @CaseyCarter please double-check.

One commit enhanced pre-existing code. uninitialized_storage now fills its char array with the fillChar instead of leaving it garbage-inited, following the example of uninitialized_fixture. None of the test code is affected by uninitialized_storage gaining a user-provided default ctor, and fillChar (0x7d) is a strict subset of garbage.

If uninitialized_meow didn't properly construct elements, this will help the test more reliably notice that, since there's no chance of garbage-init randomly resulting in an expected value.

@CaseyCarter CaseyCarter removed their assignment Nov 26, 2024
@StephanTLavavej StephanTLavavej self-assigned this Dec 3, 2024
@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 649a4f2 into microsoft:main Dec 5, 2024
39 checks passed
@frederick-vs-ja frederick-vs-ja deleted the lwg-3918 branch December 5, 2024 06:47
@StephanTLavavej
Copy link
Member

💯 ⛔ 📄 📄

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
Archived in project
Development

Successfully merging this pull request may close these issues.

LWG-3918 std::uninitialized_move/_n and guaranteed copy elision
3 participants