Skip to content

Harden operator wstring_view#546

Merged
kennykerr merged 2 commits into
masterfrom
kennykerr-data
Mar 3, 2020
Merged

Harden operator wstring_view#546
kennykerr merged 2 commits into
masterfrom
kennykerr-data

Conversation

@kennykerr

Copy link
Copy Markdown
Collaborator

Some existing code relies on data returning a valid string even when the view is empty.

Comment thread strings/base_string.h
else
{
return {};
return { L"", 0 };

@kennykerr kennykerr Mar 3, 2020

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

When the hstring is empty, the wstring_view's default constructor causes the data member to return a nullptr as per the spec:

https://en.cppreference.com/w/cpp/string/basic_string_view/basic_string_view

Now instead, data will return an empty null-terminated string.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Specs? who needs em!

@kennykerr kennykerr merged commit 4b77215 into master Mar 3, 2020
@kennykerr kennykerr deleted the kennykerr-data branch March 3, 2020 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants