`<xstring>`: constexpr string element lifetime by CaseyCarter · Pull Request #3334 · microsoft/STL · GitHub
Skip to content

<xstring>: constexpr string element lifetime#3334

Merged
StephanTLavavej merged 3 commits into
microsoft:mainfrom
CaseyCarter:string-lifetime
Jan 12, 2023
Merged

<xstring>: constexpr string element lifetime#3334
StephanTLavavej merged 3 commits into
microsoft:mainfrom
CaseyCarter:string-lifetime

Conversation

@CaseyCarter

@CaseyCarter CaseyCarter commented Jan 9, 2023

Copy link
Copy Markdown
Contributor

I've never trusted our use of _Traits::assign to start the lifetimes of the elements given that, err, that's not what _Traits::assign does. Let's use a construct_at loop instead, and centralize it into a helper function instead of repeating nine times.

Test coverage is in libcxx - 7 skips fixed!

Drive-by: Use _Traits::copy instead of _Traits::move in _Construct. Since we're constructing a new string, we know the argument doesn't alias our content.

I've never trusted our use of `_Traits::assign` to start the lifetimes of the elements given that, err, that's not what `_Traits::assign` does. Let's use a `construct_at` loop instead, and centralize it into a helper function instead of repeating nine times.

Test coverage will be in a future LLVM update.

Drive-by: Use `_Traits::copy` instead of `_Traits::move` in `_Construct`. Since we're constructing a new string, we now the argument doesn't alias our content.
@CaseyCarter CaseyCarter added the bug Something isn't working label Jan 9, 2023
@CaseyCarter CaseyCarter requested a review from a team as a code owner January 9, 2023 08:09
Comment thread stl/inc/xstring Outdated

@strega-nil-ms strega-nil-ms 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.

This looks good! We may want to make _Activate_SSO_buffer call _Start_element_lifetimes as well.

@CaseyCarter

CaseyCarter commented Jan 10, 2023

Copy link
Copy Markdown
Contributor Author

Address STL's review comment, and clarify the difference between _Activate_SSO_buffer and _Start_element_lifetimes.
@StephanTLavavej StephanTLavavej self-assigned this Jan 11, 2023
@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 StephanTLavavej merged commit 72229ff into microsoft:main Jan 12, 2023
@StephanTLavavej

Copy link
Copy Markdown
Member

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.

3 participants