Subject: Re: [std-proposals] String contains member function
From: Matthew Woehlke (mwoehlke.floss_at_[hidden])
Date: 2019-05-27 14:56:20
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:
> 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*
Mind, I like consistent, easy to use API's, but I wouldn't hold your
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups