close
Skip to content

basic_zstring_view: preserve tail substr and backport contains - #665

Merged
Duncan Horn (dunhor) merged 1 commit into
microsoft:masterfrom
mmthomas:users/mmthomas/zstring-view-substr-contains
Aug 13, 2026
Merged

basic_zstring_view: preserve tail substr and backport contains#665
Duncan Horn (dunhor) merged 1 commit into
microsoft:masterfrom
mmthomas:users/mmthomas/zstring-view-substr-contains

Conversation

@mmthomas

Copy link
Copy Markdown
Contributor

Summary

  • Add a one-argument basic_zstring_view::substr(pos) overload that returns basic_zstring_view, since a tail of a null-terminated view remains null-terminated.
  • Add an explicit two-argument substr(pos, count) overload returning std::basic_string_view, since an arbitrary slice may not be null-terminated.
  • Backport the C++23 contains() overloads for earlier language modes, gated on __cpp_lib_string_contains.

This is the focused, independently reviewable subset discussed in #635. The non-null variant and its traits design are intentionally excluded and can be considered separately.

Validation

  • MSVC Debug C++17 witest.exe "[zstring_view]": 96 assertions passed.
  • MSVC Debug C++23 witest.cpplatest.exe "[zstring_view]": 98 assertions passed.

Return basic_zstring_view from the one-argument substr overload while keeping arbitrary slices as basic_string_view. Backport contains below C++23 and cover both narrow and wide views.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 5697cd0e-cf83-4d94-9f72-4b8c79379229
@mmthomas
Monroe Thomas (mmthomas) marked this pull request as ready for review August 13, 2026 17:10
@mmthomas

Copy link
Copy Markdown
Contributor Author

Duncan Horn (@dunhor) David Machaj (@dmachaj) Jon Wiswall (@jonwis) — this is the focused follow-up to #635, limited to the substr overload changes and the contains() polyfill. The non-null variant and traits design have been left out as discussed. When you have time, I’d appreciate another look.

@dmachaj David Machaj (dmachaj) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

:shipit:

@dunhor
Duncan Horn (dunhor) merged commit 63c13c0 into microsoft:master Aug 13, 2026
15 checks passed
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.

3 participants