So the actual string cannot be used as long as the substr is used?

 

That is dangerous and unexpected.
 

-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: So 01.02.2026 20:01
Betreff: Re: [std-proposals] [Idea] Null-terminated string view (c_str_view / c_wstr_view) – a simpler alternative/complement to zstring_view
An: std-proposals@lists.isocpp.org;
CC: Frederick Virchanza Gotham <cauldwell.thomas@gmail.com>;
 
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.
 
 
-- 
 Std-Proposals mailing list
 Std-Proposals@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals