Topic: String 'contains' member function


Author: Wim Leflere <wimpielef@gmail.com>
Date: Fri, 10 Aug 2018 01:16:12 -0700 (PDT)
Raw View
------=_Part_680_1943771251.1533888972051
Content-Type: multipart/alternative;
 boundary="----=_Part_681_1948453305.1533888972051"

------=_Part_681_1948453305.1533888972051
Content-Type: text/plain; charset="UTF-8"

While following the new features for C++20 I saw that 'starts_with' and 'ends_with'
will be added to std::string.
Is it time to also add a 'contains' member function to std::string?

It's a common task that is now usually accomplished by using
'string.find(substring) != npos' (SO answer
<https://stackoverflow.com/a/2340309/2298482>).
But using 'find' requires that one extra step of thinking (in my opinion).
Are we looking for the actual position? Or checking if the string contains
a substring? Or checking if the string doesn't contain a substring?

I had a look at the motivation for adding 'starts_with' and 'ends_with' in
the paper
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0457r2.html> and
you can easily use the same motivation to add 'contains'.

The usage of 'find' as 'contains' seems to be higher than the usage of
'find' for 'starts_with'.
Contains usage: debian code search 'find [!=]= npos' (16235 results)
<http://debian code search 'find [!=]= npos' (16235 results)>
Starts with usage: debian code search 'find == 0' (5486 results)
<https://codesearch.debian.net/search?q=%5C.find%5C%28.*%3F%5C%29+*%3D%3D+*0>

--
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/96fc13fa-35ef-4fff-ae56-802c1d368b79%40isocpp.org.

------=_Part_681_1948453305.1533888972051
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><font face=3D"arial, sans-serif" size=3D"2">While fol=
lowing the new features for C++20 I saw that &#39;starts_with&#39; and &#39=
;<span style=3D"color: rgb(0, 0, 0);">ends_with&#39; will be added to std::=
string.</span></font></div><font face=3D"arial, sans-serif" size=3D"2">Is i=
t time to also add a &#39;contains&#39; member function to std::string?</fo=
nt><div><font face=3D"arial, sans-serif" size=3D"2"><br></font><div><font f=
ace=3D"arial, sans-serif" size=3D"2">It&#39;s a common task that is now usu=
ally accomplished by using &#39;string.find(substring) !=3D npos&#39; (<a h=
ref=3D"https://stackoverflow.com/a/2340309/2298482">SO answer</a>).</font><=
/div><div><font face=3D"arial, sans-serif" size=3D"2">But using &#39;find&#=
39; requires that one extra step of thinking (in my opinion).<br>Are we loo=
king for the actual position? Or checking if the string contains a substrin=
g? Or checking if the string doesn&#39;t contain a substring?<br></font><di=
v><font face=3D"arial, sans-serif"><br></font></div><div>I had a look at th=
e motivation for adding=C2=A0<span style=3D"font-size: small; font-family: =
arial, sans-serif;">&#39;starts_with&#39; and &#39;</span><span style=3D"fo=
nt-size: small; font-family: arial, sans-serif; color: rgb(0, 0, 0);">ends_=
with&#39; in the <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/pap=
ers/2017/p0457r2.html">paper</a>=C2=A0and you can easily use the same motiv=
ation to add &#39;contains&#39;.</span></div><div><span style=3D"font-size:=
 small; font-family: arial, sans-serif; color: rgb(0, 0, 0);"><br></span></=
div><div><font color=3D"#000000" face=3D"arial, sans-serif" size=3D"2">The =
usage of &#39;find&#39; as &#39;contains&#39; seems to be higher than the u=
sage of &#39;find&#39; for &#39;starts_with&#39;.</font></div><div><font co=
lor=3D"#000000" face=3D"arial, sans-serif" size=3D"2">Contains usage:=C2=A0=
<a href=3D"http://debian code search &#39;find [!=3D]=3D npos&#39;  (16235 =
results)">debian code search &#39;find [!=3D]=3D npos&#39; (16235 results)<=
/a><br></font></div><div><span style=3D"font-size: small; font-family: aria=
l, sans-serif; color: rgb(0, 0, 0);">Starts with usage:=C2=A0<a href=3D"htt=
ps://codesearch.debian.net/search?q=3D%5C.find%5C%28.*%3F%5C%29+*%3D%3D+*0"=
>debian code search &#39;find =3D=3D 0&#39; (5486 results)</a></span></div>=
</div></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/96fc13fa-35ef-4fff-ae56-802c1d368b79%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/96fc13fa-35ef-4fff-ae56-802c1d368b79=
%40isocpp.org</a>.<br />

------=_Part_681_1948453305.1533888972051--

------=_Part_680_1943771251.1533888972051--

.


Author: Wim Leflere <wimpielef@gmail.com>
Date: Fri, 10 Aug 2018 01:22:47 -0700 (PDT)
Raw View
------=_Part_607_535770950.1533889367498
Content-Type: multipart/alternative;
 boundary="----=_Part_608_111831871.1533889367498"

------=_Part_608_111831871.1533889367498
Content-Type: text/plain; charset="UTF-8"

Working contains usage link
debian code search 'find [!=]= npos' (16235 results)
<https://codesearch.debian.net/search?q=%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos>

--
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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org.

------=_Part_608_111831871.1533889367498
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Working contains usage link<div><a href=3D"https://codesea=
rch.debian.net/search?q=3D%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3=
A%3Astring%3A%3Anpos">debian code search &#39;find [!=3D]=3D npos&#39; (162=
35 results)</a><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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809=
%40isocpp.org</a>.<br />

------=_Part_608_111831871.1533889367498--

------=_Part_607_535770950.1533889367498--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Fri, 10 Aug 2018 11:09:03 +0100
Raw View
--0000000000005104a8057311ef60
Content-Type: text/plain; charset="UTF-8"

I agree that str.contains(const std::string&) -> bool would be useful.

Note, though, that a lot of the results in that link use the position
itself afterwards, so it isn't quite as bad as it seems. For example, the
3rd match:

*+            if (((strippatt = ph.find("->")) != std::string::npos) &&*
+                    (strippatt > 0) && (strippatt < ph.size() - 2)) {
+                wordpart = ph.substr(strippatt



On Fri, 10 Aug 2018, 09:22 Wim Leflere, <wimpielef@gmail.com> wrote:

> Working contains usage link
> debian code search 'find [!=]= npos' (16235 results)
> <https://codesearch.debian.net/search?q=%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos>
>
> --
> 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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_MR4EUAZh6bnao6uw%40mail.gmail.com.

--0000000000005104a8057311ef60
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div>I agree that str.contains(const std::string&amp;) -&=
gt; bool would be useful.<div dir=3D"auto"><br></div><div dir=3D"auto">Note=
, though, that a lot of the results in that link use the position itself af=
terwards, so it isn&#39;t quite as bad as it seems. For example, the 3rd ma=
tch:</div><div dir=3D"auto"><br></div><div dir=3D"auto"><pre style=3D"white=
-space:pre-wrap;word-wrap:break-word;letter-spacing:0.15px;margin-top:0px!i=
mportant;margin-bottom:0px!important;padding:0px!important;font-family:inco=
nsolata,monospace!important;font-size:14px!important"><strong>+            =
if (((strippatt =3D ph.find(&quot;-&gt;&quot;)) !=3D std::string::npos) &am=
p;&amp;</strong><br>+                    (strippatt &gt; 0) &amp;&amp; (str=
ippatt &lt; ph.size() - 2)) {<br>+                wordpart =3D ph.substr(st=
rippatt</pre></div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">On F=
ri, 10 Aug 2018, 09:22 Wim Leflere, &lt;<a href=3D"mailto:wimpielef@gmail.c=
om">wimpielef@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr">Working contains usage link<div><a href=3D"https://cod=
esearch.debian.net/search?q=3D%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*s=
td%3A%3Astring%3A%3Anpos" target=3D"_blank" rel=3D"noreferrer">debian code =
search &#39;find [!=3D]=3D npos&#39; (16235 results)</a><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" target=3D"_=
blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org</a>.<br>
</blockquote></div></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/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_=
MR4EUAZh6bnao6uw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCN1KiUQ=
d992cpQknHk2KU6SBgDjk_MR4EUAZh6bnao6uw%40mail.gmail.com</a>.<br />

--0000000000005104a8057311ef60--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Fri, 10 Aug 2018 11:18:43 +0100
Raw View
--0000000000002898d10573121255
Content-Type: text/plain; charset="UTF-8"

Now that we have std::optional...

auto maybe_find(char_type const* thing, size_t from) ->
std::optional<size_t>;

....we'd have the best of both worlds:

if(auto found = s.maybe_find("foo") )
{
  something(s, *found);
}


On Fri, 10 Aug 2018 at 11:09, Jake Arkinstall <jake.arkinstall@gmail.com>
wrote:

> I agree that str.contains(const std::string&) -> bool would be useful.
>
> Note, though, that a lot of the results in that link use the position
> itself afterwards, so it isn't quite as bad as it seems. For example, the
> 3rd match:
>
> *+            if (((strippatt = ph.find("->")) != std::string::npos) &&*
> +                    (strippatt > 0) && (strippatt < ph.size() - 2)) {
> +                wordpart = ph.substr(strippatt
>
>
>
> On Fri, 10 Aug 2018, 09:22 Wim Leflere, <wimpielef@gmail.com> wrote:
>
>> Working contains usage link
>> debian code search 'find [!=]= npos' (16235 results)
>> <https://codesearch.debian.net/search?q=%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos>
>>
>> --
>> 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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_MR4EUAZh6bnao6uw%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_MR4EUAZh6bnao6uw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

--
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/CALvx3hY_ceD_4m8-Uu08n8cgR41-K98kAnOZFpjkwamrf9RMdw%40mail.gmail.com.

--0000000000002898d10573121255
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Now that we have std::optional...<div><br></div><div><font=
 face=3D"monospace, monospace"><span style=3D"font-size:small;background-co=
lor:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:in=
itial;float:none;display:inline">auto maybe_find(char_type const* thing, si=
ze_t from) -&gt; std::optional&lt;size_t&gt;;<br></span></font><br>...we&#3=
9;d have the best of both worlds:<br><br><font face=3D"monospace, monospace=
">if(auto found =3D s.maybe_find(&quot;foo&quot;) )<br>{<br>=C2=A0 somethin=
g(s, *found);<br>}<br><br></font></div></div><br><div class=3D"gmail_quote"=
><div dir=3D"ltr">On Fri, 10 Aug 2018 at 11:09, Jake Arkinstall &lt;<a href=
=3D"mailto:jake.arkinstall@gmail.com">jake.arkinstall@gmail.com</a>&gt; wro=
te:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><div>I agree =
that str.contains(const std::string&amp;) -&gt; bool would be useful.<div d=
ir=3D"auto"><br></div><div dir=3D"auto">Note, though, that a lot of the res=
ults in that link use the position itself afterwards, so it isn&#39;t quite=
 as bad as it seems. For example, the 3rd match:</div><div dir=3D"auto"><br=
></div><div dir=3D"auto"><pre style=3D"white-space:pre-wrap;word-wrap:break=
-word;letter-spacing:0.15px;margin-top:0px!important;margin-bottom:0px!impo=
rtant;padding:0px!important;font-family:inconsolata,monospace!important;fon=
t-size:14px!important"><strong>+            if (((strippatt =3D ph.find(&qu=
ot;-&gt;&quot;)) !=3D std::string::npos) &amp;&amp;</strong><br>+          =
          (strippatt &gt; 0) &amp;&amp; (strippatt &lt; ph.size() - 2)) {<b=
r>+                wordpart =3D ph.substr(strippatt</pre></div><br><br><div=
 class=3D"gmail_quote"><div dir=3D"ltr">On Fri, 10 Aug 2018, 09:22 Wim Lefl=
ere, &lt;<a href=3D"mailto:wimpielef@gmail.com" target=3D"_blank">wimpielef=
@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr">Working contains usage link<div><a href=3D"https://codesearch.debi=
an.net/search?q=3D%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astri=
ng%3A%3Anpos" rel=3D"noreferrer" target=3D"_blank">debian code search &#39;=
find [!=3D]=3D npos&#39; (16235 results)</a><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" rel=3D"nore=
ferrer" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" rel=3D"noreferrer" target=3D"_blank">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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"noreferrer"=
 target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org</a>.<br>
</blockquote></div></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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_=
MR4EUAZh6bnao6uw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_MR4EUAZh6bnao6uw%40mail.gmail.c=
om</a>.<br>
</blockquote></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/CALvx3hY_ceD_4m8-Uu08n8cgR41-K98kAnOZ=
Fpjkwamrf9RMdw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hY_ceD_4m8-=
Uu08n8cgR41-K98kAnOZFpjkwamrf9RMdw%40mail.gmail.com</a>.<br />

--0000000000002898d10573121255--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 10 Aug 2018 13:23:41 +0300
Raw View
On 10 August 2018 at 13:18, Richard Hodges <hodges.r@gmail.com> wrote:
> Now that we have std::optional...
>
> auto maybe_find(char_type const* thing, size_t from) ->
> std::optional<size_t>;
>
> ...we'd have the best of both worlds:
>
> if(auto found = s.maybe_find("foo") )
> {
>   something(s, *found);
> }

Or we could just use optional<string_view>. I considered using
string_view directly, but it lacks a bool
conversion.

--
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/CAFk2RUYNPS34FAEf3gGTgRQvdsmHZ-%2B0_E69WvBLN9%3D1Zr%2BdNQ%40mail.gmail.com.

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Fri, 10 Aug 2018 11:26:20 +0100
Raw View
--0000000000001deb830573122dee
Content-Type: text/plain; charset="UTF-8"

What would that string_view point to?

On Fri, 10 Aug 2018, 11:23 Ville Voutilainen, <ville.voutilainen@gmail.com>
wrote:

> On 10 August 2018 at 13:18, Richard Hodges <hodges.r@gmail.com> wrote:
> > Now that we have std::optional...
> >
> > auto maybe_find(char_type const* thing, size_t from) ->
> > std::optional<size_t>;
> >
> > ...we'd have the best of both worlds:
> >
> > if(auto found = s.maybe_find("foo") )
> > {
> >   something(s, *found);
> > }
>
> Or we could just use optional<string_view>. I considered using
> string_view directly, but it lacks a bool
> conversion.
>
> --
> 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/CAFk2RUYNPS34FAEf3gGTgRQvdsmHZ-%2B0_E69WvBLN9%3D1Zr%2BdNQ%40mail.gmail.com
> .
>

--
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/CAC%2B0CCN3WkEaGOxbPTAir5qbHWsRdXYzXbJE%2BD89PHixKtnuxQ%40mail.gmail.com.

--0000000000001deb830573122dee
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div>What would that string_view point to?<br><br><div cl=
ass=3D"gmail_quote"><div dir=3D"ltr">On Fri, 10 Aug 2018, 11:23 Ville Vouti=
lainen, &lt;<a href=3D"mailto:ville.voutilainen@gmail.com">ville.voutilaine=
n@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 10 Au=
gust 2018 at 13:18, Richard Hodges &lt;<a href=3D"mailto:hodges.r@gmail.com=
" target=3D"_blank" rel=3D"noreferrer">hodges.r@gmail.com</a>&gt; wrote:<br=
>
&gt; Now that we have std::optional...<br>
&gt;<br>
&gt; auto maybe_find(char_type const* thing, size_t from) -&gt;<br>
&gt; std::optional&lt;size_t&gt;;<br>
&gt;<br>
&gt; ...we&#39;d have the best of both worlds:<br>
&gt;<br>
&gt; if(auto found =3D s.maybe_find(&quot;foo&quot;) )<br>
&gt; {<br>
&gt;=C2=A0 =C2=A0something(s, *found);<br>
&gt; }<br>
<br>
Or we could just use optional&lt;string_view&gt;. I considered using<br>
string_view directly, but it lacks a bool<br>
conversion.<br>
<br>
-- <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%2Bunsubscribe@isocpp.org" target=3D=
"_blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">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/CAFk2RUYNPS34FAEf3gGTgRQvdsmHZ-%2B0_E=
69WvBLN9%3D1Zr%2BdNQ%40mail.gmail.com" rel=3D"noreferrer noreferrer" target=
=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CA=
Fk2RUYNPS34FAEf3gGTgRQvdsmHZ-%2B0_E69WvBLN9%3D1Zr%2BdNQ%40mail.gmail.com</a=
>.<br>
</blockquote></div></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/CAC%2B0CCN3WkEaGOxbPTAir5qbHWsRdXYzXb=
JE%2BD89PHixKtnuxQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCN3Wk=
EaGOxbPTAir5qbHWsRdXYzXbJE%2BD89PHixKtnuxQ%40mail.gmail.com</a>.<br />

--0000000000001deb830573122dee--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 10 Aug 2018 13:30:34 +0300
Raw View
On 10 August 2018 at 13:26, Jake Arkinstall <jake.arkinstall@gmail.com> wrote:
> What would that string_view point to?

I don't understand the question. It would point to the substring in
the string, or to nothing.

--
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/CAFk2RUZ4ENgKakL99jrDhkoAtDUpkUEtGNEzxHUqtGRq3s5uEg%40mail.gmail.com.

.


Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Fri, 10 Aug 2018 03:35:31 -0700 (PDT)
Raw View
------=_Part_731_1876069974.1533897331465
Content-Type: multipart/alternative;
 boundary="----=_Part_732_889625091.1533897331465"

------=_Part_732_889625091.1533897331465
Content-Type: text/plain; charset="UTF-8"

t.starts_with(u) == (t.compare(0, u.size(), u) == 0)
t.ends_with(u)   == (t.size() >= u.size() &&
                     t.compare(t.size()-u.size(), u.size(), u) == 0)

t.contains(u)    == (t.find(u) != t.npos)

I'm note sure we need any more adopter functions, we already have the
functionality.

On Friday, August 10, 2018 at 10:16:12 AM UTC+2, Wim Leflere wrote:
>
> While following the new features for C++20 I saw that 'starts_with' and 'ends_with'
> will be added to std::string.
> Is it time to also add a 'contains' member function to std::string?
>
> It's a common task that is now usually accomplished by using
> 'string.find(substring) != npos' (SO answer
> <https://stackoverflow.com/a/2340309/2298482>).
> But using 'find' requires that one extra step of thinking (in my opinion).
> Are we looking for the actual position? Or checking if the string contains
> a substring? Or checking if the string doesn't contain a substring?
>
> I had a look at the motivation for adding 'starts_with' and 'ends_with'
> in the paper
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0457r2.html> and
> you can easily use the same motivation to add 'contains'.
>
> The usage of 'find' as 'contains' seems to be higher than the usage of
> 'find' for 'starts_with'.
> Contains usage: debian code search 'find [!=]= npos' (16235 results)
> Starts with usage: debian code search 'find == 0' (5486 results)
> <https://codesearch.debian.net/search?q=%5C.find%5C%28.*%3F%5C%29+*%3D%3D+*0>
>

--
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/293409dc-394e-4745-a366-9187075c5ab3%40isocpp.org.

------=_Part_732_889625091.1533897331465
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflo=
w-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">starts_wi=
th</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">u</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">t</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
..</span><span style=3D"color: #000;" class=3D"styled-by-prettify">compare</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> u</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">size</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(),</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> u</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><div style=3D"background-color: rgb(25=
0, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border=
-width: 1px; overflow-wrap: break-word;" class=3D"prettyprint"><code class=
=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">t</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">ends_with</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">u</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0=C2=A0 </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">t.size() &gt;=3D u.size() &amp;&amp=
;<br>=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 t</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">compare</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">t.size()-u.size()</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> u</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">size</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> u</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;"=
 class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)<br><br></span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">t.contains(u)=C2=A0=C2=A0=C2=A0 =3D=3D (t.find(u) !=3D =
t.npos)<br></span></div></code></div><span style=3D"color: #000;" class=3D"=
styled-by-prettify"></span></div></code></div><br>I&#39;m note sure we need=
 any more adopter functions, we already have the functionality.<br><br>On F=
riday, August 10, 2018 at 10:16:12 AM UTC+2, Wim Leflere wrote:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><font size=3D"2" fac=
e=3D"arial, sans-serif">While following the new features for C++20 I saw th=
at &#39;starts_with&#39; and &#39;<span style=3D"color:rgb(0,0,0)">ends_wit=
h&#39; will be added to std::string.</span></font></div><font size=3D"2" fa=
ce=3D"arial, sans-serif">Is it time to also add a &#39;contains&#39; member=
 function to std::string?</font><div><font size=3D"2" face=3D"arial, sans-s=
erif"><br></font><div><font size=3D"2" face=3D"arial, sans-serif">It&#39;s =
a common task that is now usually accomplished by using &#39;string.find(su=
bstring) !=3D npos&#39; (<a href=3D"https://stackoverflow.com/a/2340309/229=
8482" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;ht=
tps://www.google.com/url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fa%2F2340309=
%2F2298482\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNElk8nNzfQtlljyTEclwYwZAj=
YMPg&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google.com/=
url?q\x3dhttps%3A%2F%2Fstackoverflow.com%2Fa%2F2340309%2F2298482\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNElk8nNzfQtlljyTEclwYwZAjYMPg&#39;;return true=
;">SO answer</a>).</font></div><div><font size=3D"2" face=3D"arial, sans-se=
rif">But using &#39;find&#39; requires that one extra step of thinking (in =
my opinion).<br>Are we looking for the actual position? Or checking if the =
string contains a substring? Or checking if the string doesn&#39;t contain =
a substring?<br></font><div><font face=3D"arial, sans-serif"><br></font></d=
iv><div>I had a look at the motivation for adding=C2=A0<span style=3D"font-=
size:small;font-family:arial,sans-serif">&#39;starts_with&#39; and &#39;</s=
pan><span style=3D"font-size:small;font-family:arial,sans-serif;color:rgb(0=
,0,0)">ends_with&#39; in the <a href=3D"http://www.open-std.org/jtc1/sc22/w=
g21/docs/papers/2017/p0457r2.html" target=3D"_blank" rel=3D"nofollow" onmou=
sedown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.=
open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2017%2Fp0457r2.html\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG6hw7-pUliOeX6m6EaBNK-k7VQUw&#39;;retu=
rn true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3=
A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2017%2Fp0457=
r2.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG6hw7-pUliOeX6m6EaBNK-k7VQU=
w&#39;;return true;">paper</a>=C2=A0and you can easily use the same motivat=
ion to add &#39;contains&#39;.</span></div><div><span style=3D"font-size:sm=
all;font-family:arial,sans-serif;color:rgb(0,0,0)"><br></span></div><div><f=
ont size=3D"2" face=3D"arial, sans-serif" color=3D"#000000">The usage of &#=
39;find&#39; as &#39;contains&#39; seems to be higher than the usage of &#3=
9;find&#39; for &#39;starts_with&#39;.</font></div><div><font size=3D"2" fa=
ce=3D"arial, sans-serif" color=3D"#000000">Contains usage:=C2=A0<a>debian c=
ode search &#39;find [!=3D]=3D npos&#39; (16235 results)</a><br></font></di=
v><div><span style=3D"font-size:small;font-family:arial,sans-serif;color:rg=
b(0,0,0)">Starts with usage:=C2=A0<a href=3D"https://codesearch.debian.net/=
search?q=3D%5C.find%5C%28.*%3F%5C%29+*%3D%3D+*0" target=3D"_blank" rel=3D"n=
ofollow" onmousedown=3D"this.href=3D&#39;https://www.google.com/url?q\x3dht=
tps%3A%2F%2Fcodesearch.debian.net%2Fsearch%3Fq%3D%255C.find%255C%2528.*%253=
F%255C%2529%2B*%253D%253D%2B*0\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGpNs=
MwdbbDoLmB3ieX6OgY5fv5eQ&#39;;return true;" onclick=3D"this.href=3D&#39;htt=
ps://www.google.com/url?q\x3dhttps%3A%2F%2Fcodesearch.debian.net%2Fsearch%3=
Fq%3D%255C.find%255C%2528.*%253F%255C%2529%2B*%253D%253D%2B*0\x26sa\x3dD\x2=
6sntz\x3d1\x26usg\x3dAFQjCNGpNsMwdbbDoLmB3ieX6OgY5fv5eQ&#39;;return true;">=
debian code search &#39;find =3D=3D 0&#39; (5486 results)</a></span></div><=
/div></div></div></blockquote></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/293409dc-394e-4745-a366-9187075c5ab3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/293409dc-394e-4745-a366-9187075c5ab3=
%40isocpp.org</a>.<br />

------=_Part_732_889625091.1533897331465--

------=_Part_731_1876069974.1533897331465--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Fri, 10 Aug 2018 13:12:48 +0100
Raw View
--000000000000d8a767057313a9d9
Content-Type: text/plain; charset="UTF-8"

What would be the use of getting a string_view containing the string you're
looking for? When you're looking for the position of a substring within a
string, it's usually to read the area outside of that substring, not the
substring itself.

Two helper functions which return optional string views for before and
after a searched substring is something I could definitely get on board
with.

On Fri, 10 Aug 2018, 11:30 Ville Voutilainen, <ville.voutilainen@gmail.com>
wrote:

> On 10 August 2018 at 13:26, Jake Arkinstall <jake.arkinstall@gmail.com>
> wrote:
> > What would that string_view point to?
>
> I don't understand the question. It would point to the substring in
> the string, or to nothing.
>
> --
> 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/CAFk2RUZ4ENgKakL99jrDhkoAtDUpkUEtGNEzxHUqtGRq3s5uEg%40mail.gmail.com
> .
>

--
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/CAC%2B0CCPi9O%2B5pNaPvS6BivMUo%3D-g9%3DPBS5_4uNogzPRe-%2BpxNA%40mail.gmail.com.

--000000000000d8a767057313a9d9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">What would be the use of getting a string_view containing=
 the string you&#39;re looking for? When you&#39;re looking for the positio=
n of a substring within a string, it&#39;s usually to read the area outside=
 of that substring, not the substring itself.<div dir=3D"auto"><br></div><d=
iv dir=3D"auto">Two helper functions which return optional string views for=
 before and after a searched substring is something I could definitely get =
on board with.</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">O=
n Fri, 10 Aug 2018, 11:30 Ville Voutilainen, &lt;<a href=3D"mailto:ville.vo=
utilainen@gmail.com">ville.voutilainen@gmail.com</a>&gt; wrote:<br></div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px =
#ccc solid;padding-left:1ex">On 10 August 2018 at 13:26, Jake Arkinstall &l=
t;<a href=3D"mailto:jake.arkinstall@gmail.com" target=3D"_blank" rel=3D"nor=
eferrer">jake.arkinstall@gmail.com</a>&gt; wrote:<br>
&gt; What would that string_view point to?<br>
<br>
I don&#39;t understand the question. It would point to the substring in<br>
the string, or to nothing.<br>
<br>
-- <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%2Bunsubscribe@isocpp.org" target=3D=
"_blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">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/CAFk2RUZ4ENgKakL99jrDhkoAtDUpkUEtGNEz=
xHUqtGRq3s5uEg%40mail.gmail.com" rel=3D"noreferrer noreferrer" target=3D"_b=
lank">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUZ=
4ENgKakL99jrDhkoAtDUpkUEtGNEzxHUqtGRq3s5uEg%40mail.gmail.com</a>.<br>
</blockquote></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/CAC%2B0CCPi9O%2B5pNaPvS6BivMUo%3D-g9%=
3DPBS5_4uNogzPRe-%2BpxNA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Df=
ooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0=
CCPi9O%2B5pNaPvS6BivMUo%3D-g9%3DPBS5_4uNogzPRe-%2BpxNA%40mail.gmail.com</a>=
..<br />

--000000000000d8a767057313a9d9--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Fri, 10 Aug 2018 13:13:51 +0100
Raw View
--0000000000009fa6cf057313ad28
Content-Type: text/plain; charset="UTF-8"

On Fri, 10 Aug 2018, 11:35 Dimitrij Mijoski, <dim.mj.p@gmail.com> wrote:

> t.starts_with(u) == (t.compare(0, u.size(), u) == 0)
> t.ends_with(u)   == (t.size() >= u.size() &&
>                      t.compare(t.size()-u.size(), u.size(), u) == 0)
>
> t.contains(u)    == (t.find(u) != t.npos)
>
> I'm note sure we need any more adopter functions, we already have the
> functionality.
>

I agree.

>

--
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/CAC%2B0CCPXiP1VADco_-scZAyh%3DysuRGreT5PPx_6iy0ghNfGKqw%40mail.gmail.com.

--0000000000009fa6cf057313ad28
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">On Fri, 10 Aug 2018, 11:35 Dimitrij Mijoski, &lt;<a href=
=3D"mailto:dim.mj.p@gmail.com">dim.mj.p@gmail.com</a>&gt; wrote:<div class=
=3D"gmail_quote" dir=3D"auto"><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187=
,187);border-style:solid;border-width:1px" class=3D"m_1043985152868666551pr=
ettyprint"><code class=3D"m_1043985152868666551prettyprint"><div class=3D"m=
_1043985152868666551subprettyprint"><span style=3D"color:#000" class=3D"m_1=
043985152868666551styled-by-prettify">t</span><span style=3D"color:#660" cl=
ass=3D"m_1043985152868666551styled-by-prettify">.</span><span style=3D"colo=
r:#000" class=3D"m_1043985152868666551styled-by-prettify">starts_with</span=
><span style=3D"color:#660" class=3D"m_1043985152868666551styled-by-prettif=
y">(</span><span style=3D"color:#000" class=3D"m_1043985152868666551styled-=
by-prettify">u</span><span style=3D"color:#660" class=3D"m_1043985152868666=
551styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_104398=
5152868666551styled-by-prettify"> </span><span style=3D"color:#660" class=
=3D"m_1043985152868666551styled-by-prettify">=3D=3D</span><span style=3D"co=
lor:#000" class=3D"m_1043985152868666551styled-by-prettify"> </span><span s=
tyle=3D"color:#660" class=3D"m_1043985152868666551styled-by-prettify">(</sp=
an><span style=3D"color:#000" class=3D"m_1043985152868666551styled-by-prett=
ify">t</span><span style=3D"color:#660" class=3D"m_1043985152868666551style=
d-by-prettify">.</span><span style=3D"color:#000" class=3D"m_10439851528686=
66551styled-by-prettify">compare</span><span style=3D"color:#660" class=3D"=
m_1043985152868666551styled-by-prettify">(</span><span style=3D"color:#066"=
 class=3D"m_1043985152868666551styled-by-prettify">0</span><span style=3D"c=
olor:#660" class=3D"m_1043985152868666551styled-by-prettify">,</span><span =
style=3D"color:#000" class=3D"m_1043985152868666551styled-by-prettify"> u</=
span><span style=3D"color:#660" class=3D"m_1043985152868666551styled-by-pre=
ttify">.</span><span style=3D"color:#000" class=3D"m_1043985152868666551sty=
led-by-prettify">size</span><span style=3D"color:#660" class=3D"m_104398515=
2868666551styled-by-prettify">(),</span><span style=3D"color:#000" class=3D=
"m_1043985152868666551styled-by-prettify"> u</span><span style=3D"color:#66=
0" class=3D"m_1043985152868666551styled-by-prettify">)</span><span style=3D=
"color:#000" class=3D"m_1043985152868666551styled-by-prettify"> </span><spa=
n style=3D"color:#660" class=3D"m_1043985152868666551styled-by-prettify">=
=3D=3D</span><span style=3D"color:#000" class=3D"m_1043985152868666551style=
d-by-prettify"> </span><span style=3D"color:#066" class=3D"m_10439851528686=
66551styled-by-prettify">0</span><span style=3D"color:#660" class=3D"m_1043=
985152868666551styled-by-prettify">)</span><span style=3D"color:#000" class=
=3D"m_1043985152868666551styled-by-prettify"><br></span><div style=3D"backg=
round-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:sol=
id;border-width:1px" class=3D"m_1043985152868666551prettyprint"><code class=
=3D"m_1043985152868666551prettyprint"><div class=3D"m_1043985152868666551su=
bprettyprint"><span style=3D"color:#000" class=3D"m_1043985152868666551styl=
ed-by-prettify">t</span><span style=3D"color:#660" class=3D"m_1043985152868=
666551styled-by-prettify">.</span><span style=3D"color:#000" class=3D"m_104=
3985152868666551styled-by-prettify">ends_with</span><span style=3D"color:#6=
60" class=3D"m_1043985152868666551styled-by-prettify">(</span><span style=
=3D"color:#000" class=3D"m_1043985152868666551styled-by-prettify">u</span><=
span style=3D"color:#660" class=3D"m_1043985152868666551styled-by-prettify"=
>)</span><span style=3D"color:#000" class=3D"m_1043985152868666551styled-by=
-prettify">=C2=A0=C2=A0 </span><span style=3D"color:#660" class=3D"m_104398=
5152868666551styled-by-prettify">=3D=3D</span><span style=3D"color:#000" cl=
ass=3D"m_1043985152868666551styled-by-prettify"> </span><span style=3D"colo=
r:#660" class=3D"m_1043985152868666551styled-by-prettify">(</span><span sty=
le=3D"color:#000" class=3D"m_1043985152868666551styled-by-prettify">t.size(=
) &gt;=3D u.size() &amp;&amp;<br>=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 t</span><span style=3D"color:#660" class=3D"m_1043985152868666551styled=
-by-prettify">.</span><span style=3D"color:#000" class=3D"m_104398515286866=
6551styled-by-prettify">compare</span><span style=3D"color:#660" class=3D"m=
_1043985152868666551styled-by-prettify">(</span><span style=3D"color:#066" =
class=3D"m_1043985152868666551styled-by-prettify">t.size()-u.size()</span><=
span style=3D"color:#660" class=3D"m_1043985152868666551styled-by-prettify"=
>,</span><span style=3D"color:#000" class=3D"m_1043985152868666551styled-by=
-prettify"> u</span><span style=3D"color:#660" class=3D"m_10439851528686665=
51styled-by-prettify">.</span><span style=3D"color:#000" class=3D"m_1043985=
152868666551styled-by-prettify">size</span><span style=3D"color:#660" class=
=3D"m_1043985152868666551styled-by-prettify">(),</span><span style=3D"color=
:#000" class=3D"m_1043985152868666551styled-by-prettify"> u</span><span sty=
le=3D"color:#660" class=3D"m_1043985152868666551styled-by-prettify">)</span=
><span style=3D"color:#000" class=3D"m_1043985152868666551styled-by-prettif=
y"> </span><span style=3D"color:#660" class=3D"m_1043985152868666551styled-=
by-prettify">=3D=3D</span><span style=3D"color:#000" class=3D"m_10439851528=
68666551styled-by-prettify"> </span><span style=3D"color:#066" class=3D"m_1=
043985152868666551styled-by-prettify">0</span><span style=3D"color:#660" cl=
ass=3D"m_1043985152868666551styled-by-prettify">)<br><br></span><span style=
=3D"color:#000" class=3D"m_1043985152868666551styled-by-prettify">t.contain=
s(u)=C2=A0=C2=A0=C2=A0 =3D=3D (t.find(u) !=3D t.npos)<br></span></div></cod=
e></div><span style=3D"color:#000" class=3D"m_1043985152868666551styled-by-=
prettify"></span></div></code></div><br>I&#39;m note sure we need any more =
adopter functions, we already have the functionality.<br></div></blockquote=
></div><div dir=3D"auto"><br></div><div dir=3D"auto">I agree.</div><div cla=
ss=3D"gmail_quote" dir=3D"auto"><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"=
ltr"></div>
</blockquote></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/CAC%2B0CCPXiP1VADco_-scZAyh%3DysuRGre=
T5PPx_6iy0ghNfGKqw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCPXiP=
1VADco_-scZAyh%3DysuRGreT5PPx_6iy0ghNfGKqw%40mail.gmail.com</a>.<br />

--0000000000009fa6cf057313ad28--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 10 Aug 2018 07:25:15 -0700 (PDT)
Raw View
------=_Part_794_1158125279.1533911116010
Content-Type: multipart/alternative;
 boundary="----=_Part_795_887703069.1533911116010"

------=_Part_795_887703069.1533911116010
Content-Type: text/plain; charset="UTF-8"

On Friday, August 10, 2018 at 6:35:31 AM UTC-4, Dimitrij Mijoski wrote:
>
> t.starts_with(u) == (t.compare(0, u.size(), u) == 0)
> t.ends_with(u)   == (t.size() >= u.size() &&
>                      t.compare(t.size()-u.size(), u.size(), u) == 0)
>
> t.contains(u)    == (t.find(u) != t.npos)
>
> I'm note sure we need any more adopter functions, we already have the
> functionality.
>

The question should not be how many "adopter[sic] functions" we have; the
question should be whether the function is justified by how it improves
code.

The equivalent of `ends_with` in particular is pretty ridiculous. It's hard
to understand exactly what it's doing without doing a full teardown of the
expression. It's very easy to get wrong. And so forth. `ends_with` is
common enough and sufficiently superior to the long-form that it's worth
doing. And since `ends_with` is worth doing, `starts_with` needs to be
there for orthogonality.

Oh, and `ends_with` can probably be implemented more efficiently when you
know that's what you're asking than with the long-form expression.

By contrast, the `contains` form is not as big of a deal. `contains` is
better, but the other version is OK. I think the thing that `contains`
offers in terms of readability is the lack of use of `!=`. If you're asking
a positive question (is X in Y), then your condition should not contain a
negation.

So... is it better? Is it better enough to be worth the committee's time?

--
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/e7b1d380-c62c-424e-be21-530911c54bc6%40isocpp.org.

------=_Part_795_887703069.1533911116010
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, August 10, 2018 at 6:35:31 AM UTC-4, Dimitrij M=
ijoski wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px"><code><div><span style=3D"color:#00=
0">t</span><span style=3D"color:#660">.</span><span style=3D"color:#000">st=
arts_with</span><span style=3D"color:#660">(</span><span style=3D"color:#00=
0">u</span><span style=3D"color:#660">)</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">(</span><span style=3D"color:#000">t</span=
><span style=3D"color:#660">.</span><span style=3D"color:#000">compare</spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#066">0</span><sp=
an style=3D"color:#660">,</span><span style=3D"color:#000"> u</span><span s=
tyle=3D"color:#660">.</span><span style=3D"color:#000">size</span><span sty=
le=3D"color:#660">(),</span><span style=3D"color:#000"> u</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">0</span><span style=3D"color:#660">)</span><span style=3D"color:=
#000"><br></span><div style=3D"background-color:rgb(250,250,250);border-col=
or:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><span s=
tyle=3D"color:#000">t</span><span style=3D"color:#660">.</span><span style=
=3D"color:#000">ends_with</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">u</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000">=C2=A0=C2=A0 </span><span style=3D"color:#660">=3D=3D</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#000">t.size() &gt;=3D u.size() &amp;&amp;<br>=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 t</span><span style=3D"color:#660">.</spa=
n><span style=3D"color:#000">compare</span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#066">t.size()-u.size()</span><span style=3D"color:=
#660">,</span><span style=3D"color:#000"> u</span><span style=3D"color:#660=
">.</span><span style=3D"color:#000">size</span><span style=3D"color:#660">=
(),</span><span style=3D"color:#000"> u</span><span style=3D"color:#660">)<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#066">0</span=
><span style=3D"color:#660">)<br><br></span><span style=3D"color:#000">t.co=
ntains(u)=C2=A0=C2=A0=C2=A0 =3D=3D (t.find(u) !=3D t.npos)<br></span></div>=
</code></div><span style=3D"color:#000"></span></div></code></div><br>I&#39=
;m note sure we need any more adopter functions, we already have the functi=
onality.<br></div></blockquote><div><br></div><div>The question should not =
be how many &quot;adopter[sic] functions&quot; we have; the question should=
 be whether the function is justified by how it improves code.<br></div><di=
v><br></div><div>The equivalent of `ends_with` in particular is pretty ridi=
culous. It&#39;s hard to understand exactly what it&#39;s doing without doi=
ng a full teardown of the expression. It&#39;s very easy to get wrong. And =
so forth. `ends_with` is common enough and sufficiently superior to the lon=
g-form that it&#39;s worth doing. And since `ends_with` is worth doing, `st=
arts_with` needs to be there for orthogonality.</div><div><br></div><div>Oh=
, and `ends_with` can probably be implemented more efficiently when you kno=
w that&#39;s what you&#39;re asking than with the long-form expression.<br>=
</div><div><br></div><div>By contrast, the `contains` form is not as big of=
 a deal. `contains` is better, but the other version is OK. I think the thi=
ng that `contains` offers in terms of readability is the lack of use of `!=
=3D`. If you&#39;re asking a positive question (is X in Y), then your condi=
tion should not contain a negation.</div><div><br></div><div>So... is it be=
tter? Is it better enough to be worth the committee&#39;s time?<br></div><b=
r></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/e7b1d380-c62c-424e-be21-530911c54bc6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e7b1d380-c62c-424e-be21-530911c54bc6=
%40isocpp.org</a>.<br />

------=_Part_795_887703069.1533911116010--

------=_Part_794_1158125279.1533911116010--

.


Author: florian.csdt@gmail.com
Date: Fri, 10 Aug 2018 09:47:02 -0700 (PDT)
Raw View
------=_Part_890_1506289559.1533919622138
Content-Type: multipart/alternative;
 boundary="----=_Part_891_1458813161.1533919622138"

------=_Part_891_1458813161.1533919622138
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



Le vendredi 10 ao=C3=BBt 2018 16:25:16 UTC+2, Nicol Bolas a =C3=A9crit :
>
> On Friday, August 10, 2018 at 6:35:31 AM UTC-4, Dimitrij Mijoski wrote:
>>
>> t.starts_with(u) =3D=3D (t.compare(0, u.size(), u) =3D=3D 0)
>> t.ends_with(u)   =3D=3D (t.size() >=3D u.size() &&
>>                      t.compare(t.size()-u.size(), u.size(), u) =3D=3D 0)
>>
>> t.contains(u)    =3D=3D (t.find(u) !=3D t.npos)
>>
>> I'm note sure we need any more adopter functions, we already have the=20
>> functionality.
>>
>
> The question should not be how many "adopter[sic] functions" we have; the=
=20
> question should be whether the function is justified by how it improves=
=20
> code.
>
> The equivalent of `ends_with` in particular is pretty ridiculous. It's=20
> hard to understand exactly what it's doing without doing a full teardown =
of=20
> the expression. It's very easy to get wrong. And so forth. `ends_with` is=
=20
> common enough and sufficiently superior to the long-form that it's worth=
=20
> doing. And since `ends_with` is worth doing, `starts_with` needs to be=20
> there for orthogonality.
>
> Oh, and `ends_with` can probably be implemented more efficiently when you=
=20
> know that's what you're asking than with the long-form expression.
>
> By contrast, the `contains` form is not as big of a deal. `contains` is=
=20
> better, but the other version is OK. I think the thing that `contains`=20
> offers in terms of readability is the lack of use of `!=3D`. If you're as=
king=20
> a positive question (is X in Y), then your condition should not contain a=
=20
> negation.
>
> So... is it better? Is it better enough to be worth the committee's time?
>
>
Also, I have the feeling that contains looks like a fast method where find=
=20
looks like a slow method: contains just check whereas find performs an=20
action.
Of course, they would do the same, but contains might give the impression=
=20
it is faster than it actually is.
=20

--=20
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 e=
mail 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/5a05c6b8-b6d0-4350-8cd4-a61410da6a14%40isocpp.or=
g.

------=_Part_891_1458813161.1533919622138
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Le vendredi 10 ao=C3=BBt 2018 16:25:16 UTC+2, Nico=
l Bolas a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr">On Friday, August 10, 2018 at 6:35:31 AM UTC-4, Dimitrij Mijo=
ski wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div sty=
le=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);borde=
r-style:solid;border-width:1px"><code><div><span style=3D"color:#000">t</sp=
an><span style=3D"color:#660">.</span><span style=3D"color:#000">starts_wit=
h</span><span style=3D"color:#660">(</span><span style=3D"color:#000">u</sp=
an><span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">=3D=3D</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">(</span><span style=3D"color:#000">t</span><span s=
tyle=3D"color:#660">.</span><span style=3D"color:#000">compare</span><span =
style=3D"color:#660">(</span><span style=3D"color:#066">0</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> u</span><span style=3D"=
color:#660">.</span><span style=3D"color:#000">size</span><span style=3D"co=
lor:#660">(),</span><span style=3D"color:#000"> u</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">0</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><b=
r></span><div style=3D"background-color:rgb(250,250,250);border-color:rgb(1=
87,187,187);border-style:solid;border-width:1px"><code><div><span style=3D"=
color:#000">t</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">ends_with</span><span style=3D"color:#660">(</span><span style=3D"co=
lor:#000">u</span><span style=3D"color:#660">)</span><span style=3D"color:#=
000">=C2=A0=C2=A0 </span><span style=3D"color:#660">=3D=3D</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=3D"=
color:#000">t.size() &gt;=3D u.size() &amp;&amp;<br>=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 t</span><span style=3D"color:#660">.</span><span s=
tyle=3D"color:#000">compare</span><span style=3D"color:#660">(</span><span =
style=3D"color:#066">t.size()-u.size()</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> u</span><span style=3D"color:#660">.</span=
><span style=3D"color:#000">size</span><span style=3D"color:#660">(),</span=
><span style=3D"color:#000"> u</span><span style=3D"color:#660">)</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">=3D=3D</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#066">0</span><span st=
yle=3D"color:#660">)<br><br></span><span style=3D"color:#000">t.contains(u)=
=C2=A0=C2=A0=C2=A0 =3D=3D (t.find(u) !=3D t.npos)<br></span></div></code></=
div><span style=3D"color:#000"></span></div></code></div><br>I&#39;m note s=
ure we need any more adopter functions, we already have the functionality.<=
br></div></blockquote><div><br></div><div>The question should not be how ma=
ny &quot;adopter[sic] functions&quot; we have; the question should be wheth=
er the function is justified by how it improves code.<br></div><div><br></d=
iv><div>The equivalent of `ends_with` in particular is pretty ridiculous. I=
t&#39;s hard to understand exactly what it&#39;s doing without doing a full=
 teardown of the expression. It&#39;s very easy to get wrong. And so forth.=
 `ends_with` is common enough and sufficiently superior to the long-form th=
at it&#39;s worth doing. And since `ends_with` is worth doing, `starts_with=
` needs to be there for orthogonality.</div><div><br></div><div>Oh, and `en=
ds_with` can probably be implemented more efficiently when you know that&#3=
9;s what you&#39;re asking than with the long-form expression.<br></div><di=
v><br></div><div>By contrast, the `contains` form is not as big of a deal. =
`contains` is better, but the other version is OK. I think the thing that `=
contains` offers in terms of readability is the lack of use of `!=3D`. If y=
ou&#39;re asking a positive question (is X in Y), then your condition shoul=
d not contain a negation.</div><div><br></div><div>So... is it better? Is i=
t better enough to be worth the committee&#39;s time?<br></div><br></div></=
blockquote><div><br></div><div>Also, I have the feeling that <span style=3D=
"font-family: courier new, monospace;">contains</span> looks like a fast me=
thod where <span style=3D"font-family: courier new, monospace;">find</span>=
 looks like a slow method: <span style=3D"font-family: courier new, monospa=
ce;">contains</span> just check whereas <span style=3D"font-family: courier=
 new, monospace;">find</span> performs an action.</div><div>Of course, they=
 would do the same, but <span style=3D"font-family: courier new, monospace;=
">contains</span> might give the impression it is faster than it actually i=
s.<br></div><div>=C2=A0</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/5a05c6b8-b6d0-4350-8cd4-a61410da6a14%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5a05c6b8-b6d0-4350-8cd4-a61410da6a14=
%40isocpp.org</a>.<br />

------=_Part_891_1458813161.1533919622138--

------=_Part_890_1506289559.1533919622138--

.


Author: Dimitrij Mijoski <dim.mj.p@gmail.com>
Date: Tue, 14 Aug 2018 10:47:44 -0700 (PDT)
Raw View
------=_Part_1982_727907971.1534268864650
Content-Type: multipart/alternative;
 boundary="----=_Part_1983_645203658.1534268864650"

------=_Part_1983_645203658.1534268864650
Content-Type: text/plain; charset="UTF-8"



On Friday, August 10, 2018 at 4:25:16 PM UTC+2, Nicol Bolas wrote:

>
> Oh, and `ends_with` can probably be implemented more efficiently when you
> know that's what you're asking than with the long-form expression.
>
> Oh, it can't. If you can, please do it and prove it with a benchmark.

--
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/f610302b-16cc-4a5b-88ad-1aae52053dc8%40isocpp.org.

------=_Part_1983_645203658.1534268864650
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, August 10, 2018 at 4:25:16 PM UTC+2, Ni=
col Bolas wrote:<br><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"><div><br></div><div>Oh, and `ends_with` can probably be implemente=
d more efficiently when you know that&#39;s what you&#39;re asking than wit=
h the long-form expression.<br></div><br></div></blockquote><div>Oh, it can=
&#39;t. If you can, please do it and prove it with a benchmark.<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/f610302b-16cc-4a5b-88ad-1aae52053dc8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f610302b-16cc-4a5b-88ad-1aae52053dc8=
%40isocpp.org</a>.<br />

------=_Part_1983_645203658.1534268864650--

------=_Part_1982_727907971.1534268864650--

.


Author: olafvdspek@gmail.com
Date: Wed, 22 Aug 2018 06:17:26 -0700 (PDT)
Raw View
------=_Part_1080_1770857415.1534943846235
Content-Type: multipart/alternative;
 boundary="----=_Part_1081_315782179.1534943846235"

------=_Part_1081_315782179.1534943846235
Content-Type: text/plain; charset="UTF-8"

Op vrijdag 10 augustus 2018 12:23:44 UTC+2 schreef Ville Voutilainen:
>
> On 10 August 2018 at 13:18, Richard Hodges <hodg...@gmail.com
> <javascript:>> wrote:
> > Now that we have std::optional...
> >
> > auto maybe_find(char_type const* thing, size_t from) ->
> > std::optional<size_t>;
> >
> > ...we'd have the best of both worlds:
> >
> > if(auto found = s.maybe_find("foo") )
> > {
> >   something(s, *found);
> > }
>
> Or we could just use optional<string_view>. I considered using
> string_view directly, but it lacks a bool
> conversion.
>

There was a proposal for that. ;)

--
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/eff48bec-ab12-477f-a19c-3c1a8bc22e0b%40isocpp.org.

------=_Part_1081_315782179.1534943846235
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Op vrijdag 10 augustus 2018 12:23:44 UTC+2 schreef Ville V=
outilainen:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 10 August 2018 a=
t 13:18, Richard Hodges &lt;<a href=3D"javascript:" target=3D"_blank" gdf-o=
bfuscated-mailto=3D"SZZrdQI2DQAJ" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;">hodg...@gmail.com</a>&gt; wrote:
<br>&gt; Now that we have std::optional...
<br>&gt;
<br>&gt; auto maybe_find(char_type const* thing, size_t from) -&gt;
<br>&gt; std::optional&lt;size_t&gt;;
<br>&gt;
<br>&gt; ...we&#39;d have the best of both worlds:
<br>&gt;
<br>&gt; if(auto found =3D s.maybe_find(&quot;foo&quot;) )
<br>&gt; {
<br>&gt; =C2=A0 something(s, *found);
<br>&gt; }
<br>
<br>Or we could just use optional&lt;string_view&gt;. I considered using
<br>string_view directly, but it lacks a bool
<br>conversion.
<br></blockquote><div><br></div><div>There was a proposal for that. ;)=C2=
=A0</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/eff48bec-ab12-477f-a19c-3c1a8bc22e0b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eff48bec-ab12-477f-a19c-3c1a8bc22e0b=
%40isocpp.org</a>.<br />

------=_Part_1081_315782179.1534943846235--

------=_Part_1080_1770857415.1534943846235--

.


Author: olafvdspek@gmail.com
Date: Wed, 22 Aug 2018 06:23:00 -0700 (PDT)
Raw View
------=_Part_1413_1549727412.1534944180883
Content-Type: multipart/alternative;
 boundary="----=_Part_1414_1013374078.1534944180883"

------=_Part_1414_1013374078.1534944180883
Content-Type: text/plain; charset="UTF-8"



Op vrijdag 10 augustus 2018 14:12:56 UTC+2 schreef Jake Arkinstall:
>
> What would be the use of getting a string_view containing the string
> you're looking for? When you're looking for the position of a substring
> within a string, it's usually to read the area outside of that substring,
> not the substring itself.
>

The after part requires you to know the length of the part you searched
for, which is inconvenient if it's a literal.


> Two helper functions which return optional string views for before and
> after a searched substring is something I could definitely get on board
> with.
>

string_view read_until(string_view&, string_view)?

Can be used as auto line = read_until(is, "\n").




--
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/b815710a-a4e7-401b-bdd6-adbb49fb78d7%40isocpp.org.

------=_Part_1414_1013374078.1534944180883
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Op vrijdag 10 augustus 2018 14:12:56 UTC+2 schreef=
 Jake Arkinstall:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"a=
uto">What would be the use of getting a string_view containing the string y=
ou&#39;re looking for? When you&#39;re looking for the position of a substr=
ing within a string, it&#39;s usually to read the area outside of that subs=
tring, not the substring itself.</div></blockquote><div><br></div><div>The =
after part requires you to know the length of the part you searched for, wh=
ich is inconvenient if it&#39;s a literal.</div><div>=C2=A0<br></div><block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto"><div dir=3D"auto">=
</div><div dir=3D"auto">Two helper functions which return optional string v=
iews for before and after a searched substring is something I could definit=
ely get on board with.</div></div></blockquote><div><br></div><div>string_v=
iew read_until(string_view&amp;, string_view)?=C2=A0</div><div><br></div><d=
iv>Can be used as auto line =3D read_until(is, &quot;\n&quot;).</div><div><=
br></div><div><br></div><div>=C2=A0<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/b815710a-a4e7-401b-bdd6-adbb49fb78d7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b815710a-a4e7-401b-bdd6-adbb49fb78d7=
%40isocpp.org</a>.<br />

------=_Part_1414_1013374078.1534944180883--

------=_Part_1413_1549727412.1534944180883--

.


Author: olafvdspek@gmail.com
Date: Wed, 22 Aug 2018 06:28:33 -0700 (PDT)
Raw View
------=_Part_526_525207176.1534944514037
Content-Type: multipart/alternative;
 boundary="----=_Part_527_1145461938.1534944514037"

------=_Part_527_1145461938.1534944514037
Content-Type: text/plain; charset="UTF-8"



Op vrijdag 10 augustus 2018 16:25:16 UTC+2 schreef Nicol Bolas:
>
> So... is it better? Is it better enough to be worth the committee's time?
>

If unified call syntax or extension methods were available we could do it
ourselves.

Actually we could just call boost::algorithm::contains or implement the
free function ourselves.

--
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/075bcfbb-59c0-47fa-8d2d-dd9648444fa6%40isocpp.org.

------=_Part_527_1145461938.1534944514037
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Op vrijdag 10 augustus 2018 16:25:16 UTC+2 schreef=
 Nicol Bolas:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">=
<div>So... is it better? Is it better enough to be worth the committee&#39;=
s time?</div></div></blockquote><div><br></div><div>If unified call syntax =
or extension methods were available we could do it ourselves.</div><div><br=
></div><div>Actually we could just call boost::algorithm::contains or imple=
ment the free function ourselves.=C2=A0<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/075bcfbb-59c0-47fa-8d2d-dd9648444fa6%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/075bcfbb-59c0-47fa-8d2d-dd9648444fa6=
%40isocpp.org</a>.<br />

------=_Part_527_1145461938.1534944514037--

------=_Part_526_525207176.1534944514037--

.


Author: Wim Leflere <wimpielef@gmail.com>
Date: Wed, 22 Aug 2018 08:18:38 -0700 (PDT)
Raw View
------=_Part_2440_387271246.1534951118123
Content-Type: multipart/alternative;
 boundary="----=_Part_2441_1168776072.1534951118123"

------=_Part_2441_1168776072.1534951118123
Content-Type: text/plain; charset="UTF-8"

On Friday, August 10, 2018 at 12:09:11 PM UTC+2, Jake Arkinstall wrote:
>
> Note, though, that a lot of the results in that link use the position
> itself afterwards, so it isn't quite as bad as it seems. For example, the
> 3rd match:
>
> *+            if (((strippatt = ph.find("->")) != std::string::npos) &&*
> +                    (strippatt > 0) && (strippatt < ph.size() - 2)) {
>
>
'find != npos' with an assignment occurs 2099 times (if my regex is correct)
debian code search '= find != npos'
<https://codesearch.debian.net/search?q=%3D+*%5Cw%2B%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos>

So 'find' as 'contains' occurs 14136 times (16235 - 2099).
Still a lot more then 'find' as 'starts with' (5486), which is now in the
standard.

--
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/0bbac25d-27eb-47bf-a8f8-42d2f0dfc9ed%40isocpp.org.

------=_Part_2441_1168776072.1534951118123
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, August 10, 2018 at 12:09:11 PM UTC+2, Jake Arki=
nstall wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto"=
><div dir=3D"auto">Note, though, that a lot of the results in that link use=
 the position itself afterwards, so it isn&#39;t quite as bad as it seems. =
For example, the 3rd match:<br></div><div dir=3D"auto"><br></div><div dir=
=3D"auto"><pre style=3D"white-space:pre-wrap;word-wrap:break-word;letter-sp=
acing:0.15px;margin-top:0px!important;margin-bottom:0px!important;padding:0=
px!important;font-family:inconsolata,monospace!important;font-size:14px!imp=
ortant"><strong>+            if (((strippatt =3D ph.find(&quot;-&gt;&quot;)=
) !=3D std::string::npos) &amp;&amp;</strong><br>+                    (stri=
ppatt &gt; 0) &amp;&amp; (strippatt &lt; ph.size() - 2)) {<br></pre></div><=
/div></blockquote><div><br></div><div>&#39;find !=3D npos&#39; with an assi=
gnment occurs 2099 times (if my regex is correct)</div><div><a href=3D"http=
s://codesearch.debian.net/search?q=3D%3D+*%5Cw%2B%5C.find%5C%28.*%3F%5C%29+=
*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos">debian code search &#39;=3D fi=
nd !=3D npos&#39;</a><br></div><div><br></div><div>So &#39;find&#39; as &#3=
9;contains&#39; occurs=C2=A014136 times (16235 - 2099).</div><div>Still a l=
ot more then &#39;find&#39; as &#39;starts with&#39; (5486), which is now i=
n the standard.</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/0bbac25d-27eb-47bf-a8f8-42d2f0dfc9ed%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0bbac25d-27eb-47bf-a8f8-42d2f0dfc9ed=
%40isocpp.org</a>.<br />

------=_Part_2441_1168776072.1534951118123--

------=_Part_2440_387271246.1534951118123--

.


Author: Wim Leflere <wimpielef@gmail.com>
Date: Wed, 22 Aug 2018 08:25:45 -0700 (PDT)
Raw View
------=_Part_2528_867361540.1534951545616
Content-Type: multipart/alternative;
 boundary="----=_Part_2529_1550081315.1534951545617"

------=_Part_2529_1550081315.1534951545617
Content-Type: text/plain; charset="UTF-8"

On Wednesday, August 22, 2018 at 3:28:34 PM UTC+2, olafv...@gmail.com wrote:
>
>
>
> Op vrijdag 10 augustus 2018 16:25:16 UTC+2 schreef Nicol Bolas:
>>
>> So... is it better? Is it better enough to be worth the committee's time?
>>
>
> If unified call syntax or extension methods were available we could do it
> ourselves.
>
> Actually we could just call boost::algorithm::contains or implement the
> free function ourselves.
>

It's a feature that a lot of people would use and that makes code more
readable.
Like starts_with, ends_with.

With regard to the free function option, this was (part of) the motivation
for starts/ends_with:

*Another considered option was to add free functions to namespace std, but
adding member functions is consistent with the existing API for compare.
Besides, as the original proposal [5] mentioned, the order of parameters of
a free function is ambiguous (starts_with(string, prefix) vs
starts_with(prefix, string)).*

--
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/3604471d-0737-4a12-bbdd-6d3dc27ea36c%40isocpp.org.

------=_Part_2529_1550081315.1534951545617
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, August 22, 2018 at 3:28:34 PM UTC+2, olafv..=
..@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><br><br>Op vrijdag 10 augustus 2018 16:25:16 UTC+2 schreef Nicol Bolas=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>So... is it =
better? Is it better enough to be worth the committee&#39;s time?</div></di=
v></blockquote><div><br></div><div>If unified call syntax or extension meth=
ods were available we could do it ourselves.</div><div><br></div><div>Actua=
lly we could just call boost::algorithm::contains or implement the free fun=
ction ourselves.=C2=A0<br></div></div></blockquote><div><br></div><div>It&#=
39;s a feature that a lot of people would use and that makes code more read=
able.</div><div>Like starts_with, ends_with.</div><div><br></div><div>With =
regard to the free function option, this was (part of) the motivation for s=
tarts/ends_with:</div><div><blockquote style=3D"margin: 0 0 0 40px; border:=
 none; padding: 0px;"><div><i>Another considered option was to add free fun=
ctions to namespace std, but adding member functions is consistent with the=
 existing API for compare. Besides, as the original proposal [5] mentioned,=
 the order of parameters of a free function is ambiguous (starts_with(strin=
g, prefix) vs starts_with(prefix, string)).</i><br></div></blockquote></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/3604471d-0737-4a12-bbdd-6d3dc27ea36c%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3604471d-0737-4a12-bbdd-6d3dc27ea36c=
%40isocpp.org</a>.<br />

------=_Part_2529_1550081315.1534951545617--

------=_Part_2528_867361540.1534951545616--

.


Author: florian.csdt@gmail.com
Date: Wed, 22 Aug 2018 08:37:59 -0700 (PDT)
Raw View
------=_Part_2416_1062243690.1534952279288
Content-Type: multipart/alternative;
 boundary="----=_Part_2417_723360203.1534952279289"

------=_Part_2417_723360203.1534952279289
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



Le mercredi 22 ao=C3=BBt 2018 17:18:38 UTC+2, Wim Leflere a =C3=A9crit :
>
> On Friday, August 10, 2018 at 12:09:11 PM UTC+2, Jake Arkinstall wrote:
>>
>> Note, though, that a lot of the results in that link use the position=20
>> itself afterwards, so it isn't quite as bad as it seems. For example, th=
e=20
>> 3rd match:
>>
>> *+            if (((strippatt =3D ph.find("->")) !=3D std::string::npos)=
 &&*
>> +                    (strippatt > 0) && (strippatt < ph.size() - 2)) {
>>
>>
> 'find !=3D npos' with an assignment occurs 2099 times (if my regex is=20
> correct)
> debian code search '=3D find !=3D npos'=20
> <https://codesearch.debian.net/search?q=3D%3D+*%5Cw%2B%5C.find%5C%28.*%3F=
%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos>
>
> So 'find' as 'contains' occurs 14136 times (16235 - 2099).
> Still a lot more then 'find' as 'starts with' (5486), which is now in the=
=20
> standard.
>

Considering two strings s1 and s2 (l1 =3D s1.size() and l2 =3D s2.size()):
complexity of s1.find(s2): O((l1 - l2) * l2)
complexity of s1.starts_with(s2): O(l2)
complexity of s1.ends_with(s2): O(l2)
complexity of an hypothetical s1.contains(s2): O((l1 - l2) * l2)

So starts_with is not only more readable code, it is also about more=20
efficient code.
contains is not about efficient code.
In that respect, contains might even be misleading as some people might=20
think contains is cheap while they will never think find is cheap.

Comparing contains vs starts_with is then not relevant.

--=20
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 e=
mail 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/0fce1553-7cf1-4fe3-894a-b88083a2122d%40isocpp.or=
g.

------=_Part_2417_723360203.1534952279289
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Le mercredi 22 ao=C3=BBt 2018 17:18:38 UTC+2, Wim =
Leflere a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr">On Friday, August 10, 2018 at 12:09:11 PM UTC+2, Jake Arkinst=
all wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><div di=
r=3D"auto">Note, though, that a lot of the results in that link use the pos=
ition itself afterwards, so it isn&#39;t quite as bad as it seems. For exam=
ple, the 3rd match:<br></div><div dir=3D"auto"><br></div><div dir=3D"auto">=
<pre style=3D"white-space:pre-wrap;word-wrap:break-word;letter-spacing:0.15=
px;margin-top:0px!important;margin-bottom:0px!important;padding:0px!importa=
nt;font-family:inconsolata,monospace!important;font-size:14px!important"><b=
>+            if (((strippatt =3D ph.find(&quot;-&gt;&quot;)) !=3D std::str=
ing::npos) &amp;&amp;</b><br>+                    (strippatt &gt; 0) &amp;&=
amp; (strippatt &lt; ph.size() - 2)) {<br></pre></div></div></blockquote><d=
iv><br></div><div>&#39;find !=3D npos&#39; with an assignment occurs 2099 t=
imes (if my regex is correct)</div><div><a href=3D"https://codesearch.debia=
n.net/search?q=3D%3D+*%5Cw%2B%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*st=
d%3A%3Astring%3A%3Anpos" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fcodesearch.d=
ebian.net%2Fsearch%3Fq%3D%253D%2B*%255Cw%252B%255C.find%255C%2528.*%253F%25=
5C%2529%2B*%255B%2521%253D%255D%253D%2B*std%253A%253Astring%253A%253Anpos\x=
26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF2zvg_gVFOWrW218XGGFCIcPDYmA&#39;;re=
turn true;" onclick=3D"this.href=3D&#39;https://www.google.com/url?q\x3dhtt=
ps%3A%2F%2Fcodesearch.debian.net%2Fsearch%3Fq%3D%253D%2B*%255Cw%252B%255C.f=
ind%255C%2528.*%253F%255C%2529%2B*%255B%2521%253D%255D%253D%2B*std%253A%253=
Astring%253A%253Anpos\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF2zvg_gVFOWrW=
218XGGFCIcPDYmA&#39;;return true;">debian code search &#39;=3D find !=3D np=
os&#39;</a><br></div><div><br></div><div>So &#39;find&#39; as &#39;contains=
&#39; occurs=C2=A014136 times (16235 - 2099).</div><div>Still a lot more th=
en &#39;find&#39; as &#39;starts with&#39; (5486), which is now in the stan=
dard.</div></div></blockquote><div><br></div><div>Considering two strings s=
1 and s2 (l1 =3D s1.size() and l2 =3D s2.size()):</div><div>complexity of s=
1.find(s2): O((l1 - l2) * l2)<div>complexity of s1.starts_with(s2): O(l2)<d=
iv>complexity of s1.ends_with(s2): O(l2)</div></div></div><div>complexity o=
f an hypothetical s1.contains(s2): O((l1 - l2) * l2)</div><div><br></div><d=
iv>So starts_with is not only more readable code, it is also about more eff=
icient code.</div><div>contains is not about efficient code.</div><div>In t=
hat respect, contains might even be misleading as some people might think c=
ontains is cheap while they will never think find is cheap.<br></div><div><=
br></div><div>Comparing contains vs starts_with is then not relevant.<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/0fce1553-7cf1-4fe3-894a-b88083a2122d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0fce1553-7cf1-4fe3-894a-b88083a2122d=
%40isocpp.org</a>.<br />

------=_Part_2417_723360203.1534952279289--

------=_Part_2416_1062243690.1534952279288--

.


Author: "'Giuseppe D'Angelo' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Wed, 22 Aug 2018 17:38:22 +0200
Raw View
This is a cryptographically signed message in MIME format.

--------------ms080607010807080707080408
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Language: en-GB

Il 10/08/2018 16:25, Nicol Bolas ha scritto:
> By contrast, the `contains` form is not as big of a deal. `contains` is
> better, but the other version is OK. I think the thing that `contains`
> offers in terms of readability is the lack of use of `!=`. If you're
> asking a positive question (is X in Y), then your condition should not
> contain a negation.
>
> So... is it better? Is it better enough to be worth the committee's time?

We've got contains() for associative containers, as a similar shorthand
over find() != some_not_found_condition, so why not for std::string too?

My 2 c,

--
Giuseppe D'Angelo | giuseppe.dangelo@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts


--
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/6eab24e5-c784-0a87-d0ed-edc4dd500907%40kdab.com.

--------------ms080607010807080707080408
Content-Type: application/pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: Firma crittografica S/MIME

MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCC
CyQwggSvMIIDl6ADAgECAhEA4CPLFRKDU4mtYW56VGdrITANBgkqhkiG9w0BAQsFADBvMQsw
CQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4
dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290
MB4XDTE0MTIyMjAwMDAwMFoXDTIwMDUzMDEwNDgzOFowgZsxCzAJBgNVBAYTAkdCMRswGQYD
VQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNP
TU9ETyBDQSBMaW1pdGVkMUEwPwYDVQQDEzhDT01PRE8gU0hBLTI1NiBDbGllbnQgQXV0aGVu
dGljYXRpb24gYW5kIFNlY3VyZSBFbWFpbCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAImxDdp6UxlOcFIdvFamBia3uEngludRq/HwWhNJFaO0jBtgvHpRQqd5jKQi3xdh
TpHVdiMKFNNKAn+2HQmAbqUEPdm6uxb+oYepLkNSQxZ8rzJQyKZPWukI2M+TJZx7iOgwZOak
+FaA/SokFDMXmaxE5WmLo0YGS8Iz1OlAnwawsayTQLm1CJM6nCpToxDbPSBhPFUDjtlOdiUC
ISn6o3xxdk/u4V+B6ftUgNvDezVSt4TeIj0sMC0xf1m9UjewM2ktQ+v61qXxl3dnUYzZ7ifr
vKUHOHaMpKk4/9+M9QOsSb7K93OZOg8yq5yVOhM9DkY6V3RhUL7GQD/L5OKfoiECAwEAAaOC
ARcwggETMB8GA1UdIwQYMBaAFK29mHo0tCb3+sQmVO8DveAky1QaMB0GA1UdDgQWBBSSYWuC
4aKgqk/sZ/HCo/e0gADB7DAOBgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADAd
BgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMEQGA1Ud
HwQ9MDswOaA3oDWGM2h0dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9BZGRUcnVzdEV4dGVybmFs
Q0FSb290LmNybDA1BggrBgEFBQcBAQQpMCcwJQYIKwYBBQUHMAGGGWh0dHA6Ly9vY3NwLnVz
ZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQELBQADggEBABsqbqxVwTqriMXY7c1V86prYSvACRAj
mQ/FZmpvsfW0tXdeDwJhAN99Bf4Ss6SAgAD8+x1banICCkG8BbrBWNUmwurVTYT7/oKYz1gb
4yJjnFL4uwU2q31Ypd6rO2Pl2tVz7+zg+3vio//wQiOcyraNTT7kSxgDsqgt1Ni7QkuQaYUQ
26Y3NOh74AEQpZzKOsefT4g0bopl0BqKu6ncyso20fT8wmQpNa/WsadxEdIDQ7GPPprsnjJT
9HaSyoY0B7ksyuYcStiZDcGG4pCS+1pCaiMhEOllx/XVu37qjIUgAmLq0ToHLFnFmTPyOInl
tukWeh95FPZKEBom+nyK+5swggZtMIIFVaADAgECAhBFV52OgCPAMZmqkvaDgfOpMA0GCSqG
SIb3DQEBCwUAMIGbMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVy
MRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01PRE8gQ0EgTGltaXRlZDFBMD8GA1UE
AxM4Q09NT0RPIFNIQS0yNTYgQ2xpZW50IEF1dGhlbnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1h
aWwgQ0EwHhcNMTYwNTIwMDAwMDAwWhcNMTkwNTIwMjM1OTU5WjCCAWIxCzAJBgNVBAYTAlNF
MQ8wDQYDVQQREwY2ODMgMzExEjAQBgNVBAgTCVZhZXJtbGFuZDEQMA4GA1UEBxMHSGFnZm9y
czEYMBYGA1UECRMPTm9ycmluZ3MgdmFlZyAyMQ8wDQYDVQQSEwZCb3ggMzAxJjAkBgNVBAoM
HUtsYXLDpGx2ZGFsZW5zIERhdGFrb25zdWx0IEFCMR0wGwYDVQQLExRBIEtEQUIgR3JvdXAg
Q29tcGFueTFDMEEGA1UECww6SXNzdWVkIHRocm91Z2ggS2xhcsOkbHZkYWxlbnMgRGF0YWtv
bnN1bHQgQUIgRS1QS0kgTWFuYWdlcjEfMB0GA1UECxMWQ29ycG9yYXRlIFNlY3VyZSBFbWFp
bDEaMBgGA1UEAxMRR2l1c2VwcGUgRCdBbmdlbG8xKDAmBgkqhkiG9w0BCQEWGWdpdXNlcHBl
LmRhbmdlbG9Aa2RhYi5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDRpPKl
9ZyLpQ/UM/zcNoWrwg55cHjp+qvQT3iivgGuxP7Tg6ceAo72kwlIyZ6Prys0/wn6FN7mFZi/
r4jIV+pCgBjRjRcEHhplGA7MOmHCIznYqaBrVJmaZr3XaRukQbQNXTwhaQGOPG3Ss/LGnJyx
YT6i0WAWHSw8tWhoASCbWHt8x0lBR2ZqWbTI3sAyzhCKgijlscAQV79L8/KjQ1gSc1tMtk0o
+H2kts+h3UaUHMTxd3yy6T2azN7p7wgwUXTHD8PkvAD00OYlUYjerGWrj+bGOeX8fC5FXzH+
57PN/I1i/BVZsnMPFsYD3ItprlXF4SvUZypL9UGVvrTM4SUtAgMBAAGjggHhMIIB3TAfBgNV
HSMEGDAWgBSSYWuC4aKgqk/sZ/HCo/e0gADB7DAdBgNVHQ4EFgQUyvEat8Z6o8LLMytHSJlF
ACE1k8swDgYDVR0PAQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUH
AwQGCCsGAQUFBwMCMEYGA1UdIAQ/MD0wOwYMKwYBBAGyMQECAQMFMCswKQYIKwYBBQUHAgEW
HWh0dHBzOi8vc2VjdXJlLmNvbW9kby5uZXQvQ1BTMF0GA1UdHwRWMFQwUqBQoE6GTGh0dHA6
Ly9jcmwuY29tb2RvY2EuY29tL0NPTU9ET1NIQTI1NkNsaWVudEF1dGhlbnRpY2F0aW9uYW5k
U2VjdXJlRW1haWxDQS5jcmwwgZAGCCsGAQUFBwEBBIGDMIGAMFgGCCsGAQUFBzAChkxodHRw
Oi8vY3J0LmNvbW9kb2NhLmNvbS9DT01PRE9TSEEyNTZDbGllbnRBdXRoZW50aWNhdGlvbmFu
ZFNlY3VyZUVtYWlsQ0EuY3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5jb21vZG9jYS5j
b20wJAYDVR0RBB0wG4EZZ2l1c2VwcGUuZGFuZ2Vsb0BrZGFiLmNvbTANBgkqhkiG9w0BAQsF
AAOCAQEAHrkxe9D8UqNNq5kfMk7c3SBS6KeZrVJcO/W095VYnsAGnm9C+F75oxYbr54oFlfs
N1Jfn7lyN0CxRyaptiWpL67dgkNYk0LHT2/3vdAnEwPiwk/nW0HGAZ1EZ+VplkFCMtyWjmo6
RBaaWCUX2z0XYnfCzAm0UwKilkj8x/3EagpYlIBwEywPcEFJioPhdnGqs52pCY+edDFIx95a
Bremy6bXYDeDZGwBO+Ya0dyeSIovZ3mO/M9yogoAXWbM7tVBbTy4ztBNnJOjncQD4WH8Dho7
K7x8l2pgzPxH93Gwt+hmJeFCi86Ajh4CFl+ODPCo8KypKSaNzU2SIq5djsYkGDGCBEEwggQ9
AgEBMIGwMIGbMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAw
DgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01PRE8gQ0EgTGltaXRlZDFBMD8GA1UEAxM4
Q09NT0RPIFNIQS0yNTYgQ2xpZW50IEF1dGhlbnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1haWwg
Q0ECEEVXnY6AI8AxmaqS9oOB86kwDQYJYIZIAWUDBAIBBQCgggJhMBgGCSqGSIb3DQEJAzEL
BgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTE4MDgyMjE1MzgyMlowLwYJKoZIhvcNAQkE
MSIEIGkINrqPQTf2eCXHOwHn6lAg/K2kw6GcYAuGsB61A3SBMGwGCSqGSIb3DQEJDzFfMF0w
CwYJYIZIAWUDBAEqMAsGCWCGSAFlAwQBAjAKBggqhkiG9w0DBzAOBggqhkiG9w0DAgICAIAw
DQYIKoZIhvcNAwICAUAwBwYFKw4DAgcwDQYIKoZIhvcNAwICASgwgcEGCSsGAQQBgjcQBDGB
szCBsDCBmzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G
A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxQTA/BgNVBAMTOENP
TU9ETyBTSEEtMjU2IENsaWVudCBBdXRoZW50aWNhdGlvbiBhbmQgU2VjdXJlIEVtYWlsIENB
AhBFV52OgCPAMZmqkvaDgfOpMIHDBgsqhkiG9w0BCRACCzGBs6CBsDCBmzELMAkGA1UEBhMC
R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxQTA/BgNVBAMTOENPTU9ETyBTSEEtMjU2IENsaWVu
dCBBdXRoZW50aWNhdGlvbiBhbmQgU2VjdXJlIEVtYWlsIENBAhBFV52OgCPAMZmqkvaDgfOp
MA0GCSqGSIb3DQEBAQUABIIBAK/uNtAjFFcepiiTTawSoxqR5RdFfxXNfaFvBj/iXCbZ5pm+
MYBIa2TwR85w3tf2sCUnpqpx4UwyfxGQGTy/GnKUmFhlRuVRbgyS9aW9OvRnNSxKsS0jXxYp
cVtC/Hp8GLZVP1tLaOpBSFW5TOAZBnAqeELwWYswRHdumpJIGjokJ6pQ4QZhWY/jPgr0bl5s
x4lLscdsyFVLGwSWhmyP9vMT6WY8SrfZK3p5LBoWZTJvD0c09ZQYYBY/i8O9S8XW+7zU2LG2
9eoCuTg3ND5vEGDxVBOV7MBv08NFj46AbVRdMhaA77khcpAdmivO2MslmLglDmausp+IdSzr
+R+LFdIAAAAAAAA=
--------------ms080607010807080707080408--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Wed, 22 Aug 2018 18:06:58 +0100
Raw View
--000000000000a2f4180574092b40
Content-Type: text/plain; charset="UTF-8"

On Wed, Aug 22, 2018 at 4:38 PM, 'Giuseppe D'Angelo' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org> wrote:

> Il 10/08/2018 16:25, Nicol Bolas ha scritto:
>
>> By contrast, the `contains` form is not as big of a deal. `contains` is
>> better, but the other version is OK. I think the thing that `contains`
>> offers in terms of readability is the lack of use of `!=`. If you're asking
>> a positive question (is X in Y), then your condition should not contain a
>> negation.
>>
>> So... is it better? Is it better enough to be worth the committee's time?
>>
>
> We've got contains() for associative containers, as a similar shorthand
> over find() != some_not_found_condition, so why not for std::string too?
>

Being pedantic, contains() would do something different altogether here.
Searching for a substring in a string is closer to searching for a
consecutive set of objects in a container.

--
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/CAC%2B0CCPHowT7TEs2qcYO6ChYJXDcAUt%3D1u12NiHG%2BQOAjcjUdg%40mail.gmail.com.

--000000000000a2f4180574092b40
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div></div><div class=3D"gmail_extra"><br><div class=3D"gm=
ail_quote">On Wed, Aug 22, 2018 at 4:38 PM, &#39;Giuseppe D&#39;Angelo&#39;=
 via ISO C++ Standard - Future Proposals <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:std-proposals@isocpp.org" target=3D"_blank">std-proposals@isocpp.org<=
/a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:=
0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">Il=
 10/08/2018 16:25, Nicol Bolas ha scritto:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
By contrast, the `contains` form is not as big of a deal. `contains` is bet=
ter, but the other version is OK. I think the thing that `contains` offers =
in terms of readability is the lack of use of `!=3D`. If you&#39;re asking =
a positive question (is X in Y), then your condition should not contain a n=
egation.<br>
<br>
So... is it better? Is it better enough to be worth the committee&#39;s tim=
e?<br>
</blockquote>
<br></span>
We&#39;ve got contains() for associative containers, as a similar shorthand=
 over find() !=3D some_not_found_condition, so why not for std::string too?=
<br></blockquote><div><br></div><div><div>Being pedantic, contains() would =
do something different altogether here.
Searching for a substring in a string is closer to searching for a=20
consecutive set of objects in a container.</div></div></div></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/CAC%2B0CCPHowT7TEs2qcYO6ChYJXDcAUt%3D=
1u12NiHG%2BQOAjcjUdg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCPH=
owT7TEs2qcYO6ChYJXDcAUt%3D1u12NiHG%2BQOAjcjUdg%40mail.gmail.com</a>.<br />

--000000000000a2f4180574092b40--

.


Author: Dan Raviv <dan.raviv@gmail.com>
Date: Wed, 22 Aug 2018 22:04:52 +0300
Raw View
--Apple-Mail-AC1F2993-B82B-4175-A1FF-7F1CFBB043A5
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This is great and allows more functionality than the proposed contains does=
.. But wouldn=E2=80=99t constructing an optional be considered too much of a=
 price to pay in case you don=E2=80=99t need it, and are only actually inte=
rested in the bool result?

Personally, I would be happy to get both contains and maybe_find (in case m=
y overhead concern is indeed valid).

> On 10 Aug 2018, at 13:18, Richard Hodges <hodges.r@gmail.com> wrote:
>=20
> Now that we have std::optional...
>=20
> auto maybe_find(char_type const* thing, size_t from) -> std::optional<siz=
e_t>;
>=20
> ...we'd have the best of both worlds:
>=20
> if(auto found =3D s.maybe_find("foo") )
> {
>   something(s, *found);
> }
>=20
>=20
>> On Fri, 10 Aug 2018 at 11:09, Jake Arkinstall <jake.arkinstall@gmail.com=
> wrote:
>> I agree that str.contains(const std::string&) -> bool would be useful.
>>=20
>> Note, though, that a lot of the results in that link use the position it=
self afterwards, so it isn't quite as bad as it seems. For example, the 3rd=
 match:
>>=20
>> +            if (((strippatt =3D ph.find("->")) !=3D std::string::npos) =
&&
>> +                    (strippatt > 0) && (strippatt < ph.size() - 2)) {
>> +                wordpart =3D ph.substr(strippatt
>>=20
>>=20
>>> On Fri, 10 Aug 2018, 09:22 Wim Leflere, <wimpielef@gmail.com> wrote:
>>> Working contains usage link
>>> debian code search 'find [!=3D]=3D npos' (16235 results)
>>> --=20
>>> You received this message because you are subscribed to the Google Grou=
ps "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/is=
ocpp.org/d/msgid/std-proposals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocp=
p.org.
>>=20
>> --=20
>> You received this message because you are subscribed to the Google Group=
s "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n 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/iso=
cpp.org/d/msgid/std-proposals/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_MR4EUAZh=
6bnao6uw%40mail.gmail.com.
>=20
> --=20
> 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/isoc=
pp.org/d/msgid/std-proposals/CALvx3hY_ceD_4m8-Uu08n8cgR41-K98kAnOZFpjkwamrf=
9RMdw%40mail.gmail.com.

--=20
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 e=
mail 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/FF0FF2ED-E3B2-452A-AC4C-8AC6E207BB37%40gmail.com=
..

--Apple-Mail-AC1F2993-B82B-4175-A1FF-7F1CFBB043A5
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div>This is great and allow=
s more functionality than the proposed contains does. But wouldn=E2=80=99t =
constructing an optional be considered too much of a price to pay in case y=
ou don=E2=80=99t need it, and are only actually interested in the bool resu=
lt?</div><div><br></div><div>Personally, I would be happy to get both conta=
ins and maybe_find (in case my overhead concern is indeed valid).</div><div=
><br>On 10 Aug 2018, at 13:18, Richard Hodges &lt;<a href=3D"mailto:hodges.=
r@gmail.com">hodges.r@gmail.com</a>&gt; wrote:<br><br></div><blockquote typ=
e=3D"cite"><div><div dir=3D"ltr">Now that we have std::optional...<div><br>=
</div><div><font face=3D"monospace, monospace"><span style=3D"font-size:sma=
ll;background-color:rgb(255,255,255);text-decoration-style:initial;text-dec=
oration-color:initial;float:none;display:inline">auto maybe_find(char_type =
const* thing, size_t from) -&gt; std::optional&lt;size_t&gt;;<br></span></f=
ont><br>...we'd have the best of both worlds:<br><br><font face=3D"monospac=
e, monospace">if(auto found =3D s.maybe_find("foo") )<br>{<br>&nbsp; someth=
ing(s, *found);<br>}<br><br></font></div></div><br><div class=3D"gmail_quot=
e"><div dir=3D"ltr">On Fri, 10 Aug 2018 at 11:09, Jake Arkinstall &lt;<a hr=
ef=3D"mailto:jake.arkinstall@gmail.com">jake.arkinstall@gmail.com</a>&gt; w=
rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"auto"><div>I agre=
e that str.contains(const std::string&amp;) -&gt; bool would be useful.<div=
 dir=3D"auto"><br></div><div dir=3D"auto">Note, though, that a lot of the r=
esults in that link use the position itself afterwards, so it isn't quite a=
s bad as it seems. For example, the 3rd match:</div><div dir=3D"auto"><br><=
/div><div dir=3D"auto"><pre style=3D"white-space:pre-wrap;word-wrap:break-w=
ord;letter-spacing:0.15px;margin-top:0px!important;margin-bottom:0px!import=
ant;padding:0px!important;font-family:inconsolata,monospace!important;font-=
size:14px!important"><strong>+            if (((strippatt =3D ph.find("-&gt=
;")) !=3D std::string::npos) &amp;&amp;</strong><br>+                    (s=
trippatt &gt; 0) &amp;&amp; (strippatt &lt; ph.size() - 2)) {<br>+         =
       wordpart =3D ph.substr(strippatt</pre></div><br><br><div class=3D"gm=
ail_quote"><div dir=3D"ltr">On Fri, 10 Aug 2018, 09:22 Wim Leflere, &lt;<a =
href=3D"mailto:wimpielef@gmail.com" target=3D"_blank">wimpielef@gmail.com</=
a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Work=
ing contains usage link<div><a href=3D"https://codesearch.debian.net/search=
?q=3D%5C.find%5C%28.*%3F%5C%29+*%5B%21%3D%5D%3D+*std%3A%3Astring%3A%3Anpos"=
 rel=3D"noreferrer" target=3D"_blank">debian code search 'find [!=3D]=3D np=
os' (16235 results)</a><br></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" 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" rel=3D"nore=
ferrer" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" rel=3D"noreferrer" target=3D"_blank">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/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"noreferrer"=
 target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/7ddd8e87-d0bb-4f51-adaa-643ed80b6809%40isocpp.org</a>.<br>
</blockquote></div></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" 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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_=
MR4EUAZh6bnao6uw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAC%2B0CCN1KiUQd992cpQknHk2KU6SBgDjk_MR4EUAZh6bnao6uw%40mail.gmail.c=
om</a>.<br>
</blockquote></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" 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/CALvx3hY_ceD_4m8-Uu08n8cgR41-K98kAnOZ=
Fpjkwamrf9RMdw%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hY_ceD_=
4m8-Uu08n8cgR41-K98kAnOZFpjkwamrf9RMdw%40mail.gmail.com</a>.<br>
</div></blockquote></body></html>

<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/FF0FF2ED-E3B2-452A-AC4C-8AC6E207BB37%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/FF0FF2ED-E3B2-452A-AC4C-8AC6E207BB37%=
40gmail.com</a>.<br />

--Apple-Mail-AC1F2993-B82B-4175-A1FF-7F1CFBB043A5--

.