Subject: Re: [std-proposals] String contains member function
From: Barry Revzin (barry.revzin_at_[hidden])
Date: 2019-05-31 07:06:27
On Thu, May 30, 2019 at 10:56 PM Mingxin Wang via Std-Proposals <
> This seems useful. However, the motivation seems not to be strong enough,
> 1. Although some other languages may have such functionality, I think
> C++ should not copy everything without a deep thinking and clear motivation.
> 2. Even it could simplify the âfind != nposâ pattern, I do not find
> this pattern widely existing in engineering.
> 3. If we take one step backward, even if it is a useful pattern, we
> may turn to regex for more readability and extendibility rather than âfind
> != nposâ.
> 4. The name has already been used in other facilities like âsetâ or
> âmapâ with completely different semantics, which may confuse the beginners
> and decrease âteachabilityâ.
> Therefore, I would suggest investigating more on the motivation. For the
> fourth comment above, I think âincludesâ could be a better name than
> Mingxin Wang
How do map::contains() and set::contains() have "completely different
semantics" than the proposed string::contains()? They seem exactly the same
to me. It's even the same motivation - wanting to avoid the boilerplate of
map.find(x) != map.end() is the same as wanting to avoid the boilerplate of
str.find(x) != npos.
STD-PROPOSALS list run by herb.sutter at gmail.com
Standard Proposals Archives on Google Groups