220 32658 <82be917c-b3c8-4cb4-bbbc-0f62ec78ce84@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: tecoberg@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: std::string::find implementation
Date: Tue, 30 May 2017 06:25:55 -0700 (PDT)
Lines: 89
Approved: news@gmane.org
Message-ID: <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_3562_1611131057.1496150755682"
X-Trace: blaine.gmane.org 1496150757 18456 195.159.176.226 (30 May 2017 13:25:57 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 30 May 2017 13:25:57 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDYIPUG7Z4MBBZHFWXEQKGQEW3BYIPI@isocpp.org Tue May 30 15:25:52 2017
Return-path: <std-proposals+bncBDYIPUG7Z4MBBZHFWXEQKGQEW3BYIPI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f71.google.com ([209.85.218.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDYIPUG7Z4MBBZHFWXEQKGQEW3BYIPI@isocpp.org>)
	id 1dFh9k-0004cX-DG
	for gclcip-std-proposals@m.gmane.org; Tue, 30 May 2017 15:25:52 +0200
Original-Received: by mail-oi0-f71.google.com with SMTP id a99sf68316873oic.8
        for <gclcip-std-proposals@m.gmane.org>; Tue, 30 May 2017 06:25:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id: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=92hYS/JrcfXEfz1BvkjVJgKQvXz/+4uKmWavoC2CxDg=;
        b=qlvvv9zBqN3EIGFmNp7l1+bxzSnzqpuSvm8BX8AlOtQQ4eLB51LQQe3d/gSCRcHqeR
         cX8GviW5v02+gOkAPJrOkpAdG9YoU3TnX07VAhDxa6gZJJiafnCw5nv2VnylDw/C40DU
         Dcm7jBehTsE8OpEJVYjQWIZHp8ZdYaqcpR/SEZjVtArDixbzgnK32i4FSwnA/EGcy9qk
         Kcpyyj1X8wyeVwKCSs87oyfBC2WRH7V8afnF5xZOvVVposjT2Q/Kn1WBACs6sFIzv6B3
         iZWc7+PvNc7RjpiSm5wrDSLHnj9PtRMgj7NOE+P/pA5frx9N3T9/IDK7vMhkffW5nZAb
         MqUw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id: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=92hYS/JrcfXEfz1BvkjVJgKQvXz/+4uKmWavoC2CxDg=;
        b=PY31kczjgV9P6zLh+iPhkQCgmtGLbCqEU47nPTPsV4kyoTbxD57q81MAVmofepo/6W
         pIXJSKjEuNnRjS0RFDvTKX/c3ghCIxaklTgzMFQRB18KvqChaE+mFjRTl70coaAJkTce
         8X02mzus5hNaoMy+cIQVTciGErKCbAFX1e5rFxO+Ou82Nir56u4e2tw/62CCoWvxye+D
         RkAaFZRWIqtdCV7Lx71sLp0PfEcHqiIycRraJx38O2f4F84rOc1SyumLFFOM/Ypj2+Ld
         W7C0IcHL0NdapQck7DIKl7MX6SEeXeaGeexlDr5tToEl59aly5H+mKN2UGVrD1fwEKCF
         NxiQ==
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:message-id: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=92hYS/JrcfXEfz1BvkjVJgKQvXz/+4uKmWavoC2CxDg=;
        b=Yb0xRkX8DI3+UHT1vLibsSDr+ve3sncJPmiiBKGKfPGRuSIpzIiAEK3Z9GYpkrXjQI
         S/HeuR48u9eM4LNePZcFh6x9L+/vbHrrgeaYmFsj9P+Da0A3mFOTYNZlejkxcziktjle
         +n7V7/dT2MoGXEdB+4vLnEV8FSeXoXEtmYcSKs+C3RnYdr32/eq1fG4Gq3IiHi92ViqN
         xWSGIhsA9HgQL34mHI1oKlUuwprESgXuABQHuZlNh00gtYrry5BZBpjdT45X4yqrsjee
         y/Wg3FqLvtly45UV5SjRVs2HW/IMcAyKnv6H8DiIswIxSBcCZlsiHGbMDUrWwE03BCke
         p3eQ==
X-Gm-Message-State: AODbwcCLi+cLbdjbO8pNC7rx3Ebip2JYoZ181CaUxCQS//dsqibtf8Ac
	pNmCnyD+6h3XNiz5
X-Received: by 10.157.40.33 with SMTP id m30mr3218439otb.102.1496150757005;
        Tue, 30 May 2017 06:25:57 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.35.25 with SMTP id j25ls727642otb.33.gmail; Tue, 30 May
 2017 06:25:56 -0700 (PDT)
X-Received: by 10.157.28.130 with SMTP id l2mr437361ota.17.1496150756133;
        Tue, 30 May 2017 06:25:56 -0700 (PDT)
X-Original-Sender: tecoberg@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:32658
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32658>

------=_Part_3562_1611131057.1496150755682
Content-Type: multipart/alternative; 
	boundary="----=_Part_3563_958530312.1496150755682"

------=_Part_3563_958530312.1496150755682
Content-Type: text/plain; charset="UTF-8"

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.

-- 
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/82be917c-b3c8-4cb4-bbbc-0f62ec78ce84%40isocpp.org.

------=_Part_3563_958530312.1496150755682
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><font size=3D"4">I figure out we can set the start point o=
f search on string but we cannot set the end. For example:<br><br></font><d=
iv 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=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 //Search for &#39;A&#39; into mystring starting on=
 position 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 quantity of characters to be searched from char*:<br><br></font><div s=
tyle=3D"margin-left: 40px;"><span style=3D"background-color: rgb(238, 238, =
238);"><font 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 confusi=
ng and it should be deprecated.<br><br>The best solution is make another fu=
nction member like <span style=3D"background-color: rgb(255, 255, 0);">std:=
:string::search</span> to replace <span style=3D"background-color: rgb(255,=
 255, 0);">std::string::find</span>. It could be like this:<br><br><span st=
yle=3D"background-color: rgb(255, 255, 0);">=C2=A0=C2=A0=C2=A0 size_t searc=
h (const string&amp; str, size_t pos =3D 0, size_t end =3D string::npos ) c=
onst noexcept;<br>=C2=A0=C2=A0=C2=A0 size_t search (const char* s, size_t p=
os =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 noexce=
pt;</span><br><br>where the size_t end is the end position in string where =
the search will be made.<br></font></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/82be917c-b3c8-4cb4-bbbc-0f62ec78ce84%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/82be917c-b3c8-4cb4-bbbc-0f62ec78ce84=
%40isocpp.org</a>.<br />

------=_Part_3563_958530312.1496150755682--

------=_Part_3562_1611131057.1496150755682--

.
