C++ Logo


Advanced search

Re: String contains member function

From: Wim Leflere <wim.leflere_at_[hidden]>
Date: Wed, 29 May 2019 09:27:27 +0200
It has a similar rationale as the starts_with/ends_with paper, which
doesn't mention the performance benefit and was accepted.

Performance shouldn't be the only benchmark to extend the standard I think.
Improving code readability and teachability for beginners and people coming
from other languages is also a good rationale to extend the standard.

Op ma 27 mei 2019 om 21:56 schreef Matthew Woehlke <mwoehlke.floss_at_[hidden]

> On 27/05/2019 14.30, Wim Leflere via Std-Proposals wrote:
> > After seeing that 'starts_with' and 'ends_with' were added to std::string
> > in C++20 (P0457), I was wondering why 'contains' was still missing as a
> > std::string member function.
> > So I wrote a proposal (starting from P0457) to add it.
> >
> > Please find the draft of the proposal here:
> >
> https://github.com/WimLeflere/cpp-papers/blob/master/string_contains_function.md
> >
> > I am looking forward to your valuable comments.
> The rationale vs. string::find is... weak. Both starts_with and
> ends_with have a clear performance benefit in addition to improved
> semantics. Even for <container>::contains (vs. count) that is the case.
> For string::contains, this isn't the case; the rationale is *purely*
> aesthetic.
> Mind, I like consistent, easy to use API's, but I wouldn't hold your
> breath...
> --
> Matthew

Received on 2019-05-29 02:29:24