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: JJ Marr <jjmarr_at_[hidden]>
Date: Mon, 2 Feb 2026 14:11:09 -0500
> The question of whether `substr` should be a `const` function is a
"yes/no" question. One of those answers is correct.

Off-topic, but can it be `constexpr` at least?

On Sun, Feb 1, 2026, 8:02 p.m. Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Sun, Feb 1, 2026 at 6:45 PM Frederick Virchanza Gotham via
> Std-Proposals <std-proposals_at_[hidden]> wrote:
> >
> > On Sun, Feb 1, 2026 at 7:40 PM Sebastian Wittmeier wrote:
> > >
> > > So the actual string cannot be used as long as the substr is used?
> > >
> > > That is dangerous and unexpected.
> >
> >
> > I worked with a guy one time who was really melodramatic and used the
> > word 'dangerous' a lot when talking about C++ code.
> >
> > If we're working on programming the microcontroller inside a
> > life-support machine ventilator, or the detonator for a missile, or
> > the thingie that keeps oxygen inside a submarine, then yeah sure we
> > can use the word 'danger' as there's the actual risk of life and limb.
> >
> > But in this context where we're playing with strings, I'm downgrading
> > your 'dangerous' to 'a little worrisome'.
> >
> > The following GodBolt shows what I had in mind:
>
> I don't know why you think linking to a piece of code is useful here.
> We understand what your code is doing. The problem is that what your
> code is doing is bad. Re-explaining what your code is doing by pasting
> a bunch of it doesn't stop it from being bad.
>
> The question of whether `substr` should be a `const` function is a
> "yes/no" question. One of those answers is correct. Your code uses the
> other answer.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2026-02-02 19:11:24