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: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sun, 1 Feb 2026 19:01:34 +0000
If I was gonna write a class along these lines, here's what I'd go for:

- In the constructor, take a pointer to a mutable null-terminated string
- In the 'substr' method, save the value of the one-past-the-last character
and replace it with a null
- When the string is reset, place the one-past-the-last character back
where it was

Of course this wouldn't be thread-safe, but it would be a nice efficient
way to manipulate and re-use null-terminated strings.

Received on 2026-02-01 19:01:37