Date: Tue, 03 Feb 2026 17:06:57 -0800
On Tuesday, 3 February 2026 13:00:18 Pacific Standard Time Ell wrote:
> OTOH producers of null-terminated strings don't know how the string is
> going to be used, so it makes sense to return a string_view with the
> added information that it's null terminated (as in
> https://eel.is/c++draft/meta.reflection#meta.syn-3). This information is
> useful even in the presence of embedded nulls (at the very least, it
> allows you to safely strlen() the string). The name "cstring_view" might
> be misleading though, if the actual C-string might be different.
If I'm producing one, then "view" is the wrong type. It should be just
std::string with a promise of not containing an embedded NUL.
> OTOH producers of null-terminated strings don't know how the string is
> going to be used, so it makes sense to return a string_view with the
> added information that it's null terminated (as in
> https://eel.is/c++draft/meta.reflection#meta.syn-3). This information is
> useful even in the presence of embedded nulls (at the very least, it
> allows you to safely strlen() the string). The name "cstring_view" might
> be misleading though, if the actual C-string might be different.
If I'm producing one, then "view" is the wrong type. It should be just
std::string with a promise of not containing an embedded NUL.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-02-04 01:07:05
