C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [Idea] Null-terminated string view (c_str_view / c_wstr_view) – a simpler alternative/complement to zstring_view

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 06 Feb 2026 12:26:24 -0800
On Friday, 6 February 2026 08:19:37 Pacific Standard Time Sebastian Wittmeier
via Std-Proposals wrote:
> A) would be good for quick estimates, e.g. buffer space
>
> B) would be a safety-feature/limit for mutable C strings, if the NUL byte
> gets overwritten

I don't think a type with "view" in the name should allow mutating, at all.

If you want to change the string, go back to the original buffer, which is
probably a std::string, std::vector, or std::span. That one will provide you
with the capacity.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-02-06 20:26:31