C++ Logo


Advanced search

Re: [std-proposals] String Slicing Draft Proposal

From: Rhidian De Wit <rhidiandewit_at_[hidden]>
Date: Tue, 26 Mar 2024 12:36:34 +0100

It returns a view in case it is called on a std::string_view, but a
std::string returning a std::string_view could lead to far more confusion,
since a string_view cannot be used in the same way as a string.
If the user wants a string_view, they can either explicitly construct a
string_view from the returned std::string, or they can call .subview() from
a string_view.

It is possible that someone uses subview() instead of substr() and might be
confused by the displayed behaviour, but that is then on the end-user to
check documentation and see what .subview() actually does.


Op di 26 mrt 2024 om 11:46 schreef Giuseppe D'Angelo via Std-Proposals <

> Hi,
> On 26/03/2024 09:57, Rhidian De Wit via Std-Proposals wrote:
> > My apologies, I accidentally uploaded an older version, the correct
> > version can be found in the attachments:
> I'm really unsure about this last revision: now you have
> std::string::subview which:
> * does not return a view (so why is it called sub *view*?);
> * has different parameters than the existing *sub*str() despite the very
> similar name, so it has a huge surprise factor if one thinks it takes
> pos+count (like substr does).
> My 2 c,
> --
> Giuseppe D'Angelo
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Rhidian De Wit
Software Engineer - Barco

Received on 2024-03-26 11:36:47