220 32660 <3fc83625-f594-42d1-bf7d-a30bf1b90a62@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: std::string::find implementation
Date: Tue, 30 May 2017 08:01:27 -0700 (PDT)
Lines: 106
Approved: news@gmane.org
Message-ID: <3fc83625-f594-42d1-bf7d-a30bf1b90a62@isocpp.org>
References: <82be917c-b3c8-4cb4-bbbc-0f62ec78ce84@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3461_2123507702.1496156488068"
X-Trace: blaine.gmane.org 1496156511 7758 195.159.176.226 (30 May 2017 15:01:51 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 30 May 2017 15:01:51 +0000 (UTC)
Cc: tecoberg@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBSESW3EQKGQEBFDPQIQ@isocpp.org Tue May 30 17:01:39 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBSESW3EQKGQEBFDPQIQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f199.google.com ([209.85.192.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBSESW3EQKGQEBFDPQIQ@isocpp.org>)
	id 1dFieQ-0001UF-0i
	for gclcip-std-proposals@m.gmane.org; Tue, 30 May 2017 17:01:38 +0200
Original-Received: by mail-pf0-f199.google.com with SMTP id e7sf99080600pfk.9
        for <gclcip-std-proposals@m.gmane.org>; Tue, 30 May 2017 08:01:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=0m8D/sdvgA3jLGVIyDDGVea9AofWbsr/8vfTWC0LacE=;
        b=dtOle2RwSzlYl4MjOBkk4hB4C78WkzLTlhBEXhEpIoD2BN1RTgoBv/X3vv/qgo65U1
         iG4B87vdrU348SPNfibEHlRAEvjlU4uPZCjo9MS3qgNf/yhM7Ixz4mcB13dzPc0MLKv8
         F+kHS4cX8L5h2ZgRhb7HVck3Ni6ErTYJGRuv4Cj6dKjGAdiDdlVJehFXTjN/XC3+M3AI
         tHUIBNif7xPJ9Q5oK42Ita2li1qpgct+DkGiLJijSBJ7uLN2o2942X0YI/gbflMbgk6i
         NW9kCR3e5/Xh0fMQyfmi1ldG/TTM/KYBn2gAAuHaC2MasPBSk8rQYLQHyyekBUgGCJD3
         LQaA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=0m8D/sdvgA3jLGVIyDDGVea9AofWbsr/8vfTWC0LacE=;
        b=KftpoQAwsBsF/EocLyxUwQ0D7QukrClxcrTAds4cMPHsOCWHVgYWTHURY35SCUViwX
         tkHKxcYxKGmJEBpuw8ybV68ZrOFaDVo2KCucSaqPGYeVqjqgzPXLHS1CXn8xFitxLVRr
         hw+13vWFEQ3WC/nWhL9775IeTmAGwTYnq77qfW9TmXOdqXPG6llzrcDSWerN7dFV5CBi
         2fvLKl59H11s1Dab0q97BDs3XLRtitQysgWC2ffxrAhqV2vdW+lMgJNZ6N52sDAGSXMm
         6HFF+ohkHk3DSsxpWc72EHSL6v/f6AeXzi+ax7YL8taiBgeMWfX5EIFR4R2qPmEHuAAb
         H6Zg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=0m8D/sdvgA3jLGVIyDDGVea9AofWbsr/8vfTWC0LacE=;
        b=jfU0GByhxUqSt2IsjCoMvGxGDQEWO9QSelbZHaEp/5bwnFnSW9Bknqw4rGJF7631bs
         Sj+EJBUbCXoVDebC87mc7cwsztrKQeemVZYXHWnwN6VRiloL93SgSRZv0nVl/krGL1kj
         hm7lTlyhC9DVnYodfOBwODuWvDi6lhgr7o/nCobbp82ZtO6bqY6vvMhx1pUKNivoTawt
         se4n+twA9Ag6Zc85XysRK/IwCf/minBeRIvyOvf0zYUDVPO2DCUHFN4hdptMbUW+uGsM
         dOUDHN3pUPUkvRlAKXHc2nxLN8xqXlvA8bXNGLede7/0l6CJXIEEki5HbmELvFWi7isn
         oLGA==
X-Gm-Message-State: AODbwcDpvxE+5Ho5rx9MXpOmBfzcQQ6Og2Zdnfx8eCNTP6MfpwRfT57X
	QBb2M61sWs+b2XeI
X-Received: by 10.98.202.72 with SMTP id n69mr7903133pfg.13.1496156489718;
        Tue, 30 May 2017 08:01:29 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.68.164 with SMTP id v36ls891364ote.28.gmail; Tue, 30 May
 2017 08:01:28 -0700 (PDT)
X-Received: by 10.157.15.157 with SMTP id d29mr394207otd.11.1496156488677;
        Tue, 30 May 2017 08:01:28 -0700 (PDT)
In-Reply-To: <82be917c-b3c8-4cb4-bbbc-0f62ec78ce84@isocpp.org>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:32660
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32660>

------=_Part_3461_2123507702.1496156488068
Content-Type: multipart/alternative; 
	boundary="----=_Part_3462_1034423566.1496156488069"

------=_Part_3462_1034423566.1496156488069
Content-Type: text/plain; charset="UTF-8"



On Tuesday, May 30, 2017 at 9:25:55 AM UTC-4, teco...@gmail.com wrote:
>
> I figure out we can set the start point of search on string but we cannot 
> set the end. For example:
>
> mystring.find('A', 10, 15);                                //Search for 
> 'A' into mystring starting on position 10 and ends on position 15 (into 
> mystring)
>
> The problem is the actual implementation allow to set the quantity of 
> characters to be searched from char*:
>
> size_t find (const char* s, size_t pos, size_type n) const;
>
> It is a little confusing and it should be deprecated.
>
> The best solution is make another function member like std::string::search 
> to replace std::string::find. It could be like this:
>
>     size_t search (const string& str, size_t pos = 0, size_t end = 
> string::npos ) const noexcept;
>     size_t search (const char* s, size_t pos = 0, size_t end = 
> string::npos) const;
>     size_t search (char c, size_t pos = 0, size_t end = string::npos) 
> const noexcept;
>
> where the size_t end is the end position in string where the search will 
> be made.
>

I'm not sure the cure here is better than the disease. With `string_view` 
available, we should just encourage people to use that. Adding *yet another* 
overload set of member functions isn't the most helpful thing we could do. 
After all, `find` will still be there.

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3fc83625-f594-42d1-bf7d-a30bf1b90a62%40isocpp.org.

------=_Part_3462_1034423566.1496156488069
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, May 30, 2017 at 9:25:55 AM UTC-4, teco=
....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><font size=3D"4">I figure out we can set the start point of search=
 on string but we cannot set the end. For example:<br><br></font><div style=
=3D"margin-left:40px"><font size=3D"4"><span style=3D"background-color:rgb(=
238,238,238)">mystring.find(&#39;A&#39;, 10, 15);=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0<wbr>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 //Search for &#39;A&#39; into mystring starting on posit=
ion 10 and ends on position 15 (into mystring)</span></font><br></div><font=
 size=3D"4"><br>The problem is the actual implementation allow to set the q=
uantity of characters to be searched from char*:<br><br></font><div style=
=3D"margin-left:40px"><span style=3D"background-color:rgb(238,238,238)"><fo=
nt size=3D"4">size_t find (const char* s, size_t pos, size_type n) const;</=
font></span><br></div><font size=3D"4"><br>It is a little confusing and it =
should be deprecated.<br><br>The best solution is make another function mem=
ber like <span style=3D"background-color:rgb(255,255,0)">std::string::searc=
h</span> to replace <span style=3D"background-color:rgb(255,255,0)">std::st=
ring::find</span>. It could be like this:<br><br><span style=3D"background-=
color:rgb(255,255,0)">=C2=A0=C2=A0=C2=A0 size_t search (const string&amp; s=
tr, size_t pos =3D 0, size_t end =3D string::npos ) const noexcept;<br>=C2=
=A0=C2=A0=C2=A0 size_t search (const char* s, size_t pos =3D 0, size_t end =
=3D string::npos) const;<br>=C2=A0=C2=A0=C2=A0 size_t search (char c, size_=
t pos =3D 0, size_t end =3D string::npos) const noexcept;</span><br><br>whe=
re the size_t end is the end position in string where the search will be ma=
de.<br></font></div></blockquote><div><br>I&#39;m not sure the cure here is=
 better than the disease. With `string_view` available, we should just enco=
urage people to use that. Adding <i>yet another</i> overload set of member =
functions isn&#39;t the most helpful thing we could do. After all, `find` w=
ill still be there.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3fc83625-f594-42d1-bf7d-a30bf1b90a62%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3fc83625-f594-42d1-bf7d-a30bf1b90a62=
%40isocpp.org</a>.<br />

------=_Part_3462_1034423566.1496156488069--

------=_Part_3461_2123507702.1496156488068--

.
