Topic: Free function std::contains in algoritm and map
Author: david.bolvansky@gmail.com
Date: Tue, 1 Aug 2017 10:22:20 -0700 (PDT)
Raw View
------=_Part_5247_132522116.1501608140972
Content-Type: multipart/alternative;
boundary="----=_Part_5248_693864134.1501608140973"
------=_Part_5248_693864134.1501608140973
Content-Type: text/plain; charset="UTF-8"
Instead of comparing with end(), there could be a new function - *contains.*
Now
if(std::find(vector.begin(), vector.end(), item) != vector.end()){
// found
} else {
// not found
}
// maps
if(map.find("key") != map.end()){
// found
} else {
// not found
}
I propose "contains" function:
if(std::contains(vector.begin(), vector.end(), item)){
// found
} else {
// not found
}
// maps
if(map.contains("key")){
// found
} else {
// not found
}
--
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/b7cc5b96-2165-4b4d-a9d3-7ddec49ca626%40isocpp.org.
------=_Part_5248_693864134.1501608140973
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Instead of comparing with end(), there could be a new func=
tion -=C2=A0<b>contains.</b><div><br></div><div>Now</div><div><br></div><di=
v><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250);=
border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; =
word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpretty=
print"><pre class=3D"lang-cpp prettyprint prettyprinted" style=3D"padding: =
5px; font-variant-numeric: inherit; font-stretch: inherit; line-height: inh=
erit; font-family: Consolas, Menlo, Monaco, "Lucida Console", &qu=
ot;Liberation Mono", "DejaVu Sans Mono", "Bitstream Ver=
a Sans Mono", "Courier New", monospace, sans-serif; vertical=
-align: baseline; width: auto; max-height: 600px; overflow: auto; backgroun=
d-color: rgb(239, 240, 241); color: rgb(57, 51, 24); word-wrap: normal;"><c=
ode style=3D"font-style: inherit; font-variant: inherit; font-weight: inher=
it; font-stretch: inherit; line-height: inherit; font-family: Consolas, Men=
lo, Monaco, "Lucida Console", "Liberation Mono", "=
DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier=
New", monospace, sans-serif; vertical-align: baseline; white-space: i=
nherit;"><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">find</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">vector</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">.</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">begin</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> vect=
or</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">end</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(),</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> item</span><span style=3D"colo=
r: #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</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> vector</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()){=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
=C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//=
found</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">else</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #800=
;" class=3D"styled-by-prettify">// not found</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br><br>=C2=A0</span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// maps</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><pre class=3D"lang-cpp prettyprint prettypr=
inted" style=3D"padding: 5px; font-variant-numeric: inherit; font-stretch: =
inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "=
Lucida Console", "Liberation Mono", "DejaVu Sans Mono&q=
uot;, "Bitstream Vera Sans Mono", "Courier New", monosp=
ace, sans-serif; vertical-align: baseline; width: auto; max-height: 600px; =
overflow: auto; color: rgb(57, 51, 24); word-wrap: normal;"><code style=3D"=
font-style: inherit; font-variant: inherit; font-weight: inherit; font-stre=
tch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, &=
quot;Lucida Console", "Liberation Mono", "DejaVu Sans M=
ono", "Bitstream Vera Sans Mono", "Courier New", m=
onospace, sans-serif; vertical-align: baseline; white-space: inherit;"><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">map</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">find</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify">"key"</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">!=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> map</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">end</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">()){</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// found</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">else</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">// not found</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span></code></pre></code></pre></div></code></div><div><br></div><di=
v><br></div>I propose "contains" function:</div><div><br></div><d=
iv><pre class=3D"lang-cpp prettyprint prettyprinted" style=3D"padding: 5px;=
font-variant-numeric: inherit; font-stretch: inherit; line-height: inherit=
; font-family: Consolas, Menlo, Monaco, "Lucida Console", "L=
iberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sa=
ns Mono", "Courier New", monospace, sans-serif; vertical-ali=
gn: baseline; width: auto; max-height: 600px; overflow: auto; background-co=
lor: rgb(239, 240, 241); word-wrap: normal;"><code style=3D"font-style: inh=
erit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; l=
ine-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Con=
sole", "Liberation Mono", "DejaVu Sans Mono", &quo=
t;Bitstream Vera Sans Mono", "Courier New", monospace, sans-=
serif; vertical-align: baseline; white-space: inherit;"><div class=3D"prett=
yprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(18=
7, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-word=
;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D=
"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">if</span><span style=
=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">std</span><span s=
tyle=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">::</span><sp=
an style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">contains</sp=
an><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify">vec=
tor</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prett=
ify">.</span><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-pret=
tify">begin</span><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-=
by-prettify">(),</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled=
-by-prettify"> vector</span><span style=3D"color: rgb(102, 102, 0);" class=
=3D"styled-by-prettify">.</span><span style=3D"color: rgb(0, 0, 136);" clas=
s=3D"styled-by-prettify">end</span><span style=3D"color: rgb(102, 102, 0);"=
class=3D"styled-by-prettify">(),</span><span style=3D"color: rgb(0, 0, 0);=
" class=3D"styled-by-prettify"> item</span><span style=3D"color: rgb(102, 1=
02, 0);" class=3D"styled-by-prettify">)){</span><span style=3D"color: rgb(0=
, 0, 0);" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: rgb(136, 0, 0);" class=3D"styled-by-prettify">// found</span><sp=
an style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><br></span><=
span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">}</spa=
n><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </span=
><span style=3D"color: rgb(0, 0, 136);" class=3D"styled-by-prettify">else</=
span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: rgb(102, 102, 0);" class=3D"styled-by-prettify">{=
</span><span style=3D"color: rgb(0, 0, 0);" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color: rgb(136, 0, 0);" class=3D"styl=
ed-by-prettify">// not found</span><span style=3D"color: rgb(0, 0, 0);" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: rgb(102, 102, 0)=
;" class=3D"styled-by-prettify">}<br><br></span><span class=3D"styled-by-pr=
ettify"><div class=3D"prettyprint" style=3D"border-width: 1px; border-style=
: solid; border-color: rgb(187, 187, 187); font-family: Arial, Helvetica, s=
ans-serif; white-space: normal; word-wrap: break-word;"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><pre class=3D"lang-cpp prettyprint p=
rettyprinted" style=3D"padding: 5px; font-variant-numeric: inherit; font-st=
retch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco,=
"Lucida Console", "Liberation Mono", "DejaVu Sans=
Mono", "Bitstream Vera Sans Mono", "Courier New",=
monospace, sans-serif; vertical-align: baseline; width: auto; max-height: =
600px; overflow: auto; background-color: rgb(239, 240, 241); word-wrap: nor=
mal;"><code style=3D"font-style: inherit; font-variant: inherit; font-weigh=
t: inherit; font-stretch: inherit; line-height: inherit; font-family: Conso=
las, Menlo, Monaco, "Lucida Console", "Liberation Mono"=
, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "=
;Courier New", monospace, sans-serif; vertical-align: baseline; white-=
space: inherit;"><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);">=C2=A0</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(136, 0, 0);">// maps</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);"><br></span><pre class=3D"lang-cpp prettyprint prettyprin=
ted" style=3D"padding: 5px; font-variant-numeric: inherit; font-stretch: in=
herit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lu=
cida Console", "Liberation Mono", "DejaVu Sans Mono&quo=
t;, "Bitstream Vera Sans Mono", "Courier New", monospac=
e, sans-serif; vertical-align: baseline; width: auto; max-height: 600px; ov=
erflow: auto; word-wrap: normal;"><code style=3D"font-style: inherit; font-=
variant: inherit; font-weight: inherit; font-stretch: inherit; line-height:=
inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console",=
"Liberation Mono", "DejaVu Sans Mono", "Bitstream=
Vera Sans Mono", "Courier New", monospace, sans-serif; vert=
ical-align: baseline; white-space: inherit;"><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 136);">if</span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(0, 0, 0);">map</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(102, 102, 0);">.</span><span class=3D"styled=
-by-prettify"><font color=3D"#000000">contains</font></span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);">"key"</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)=
</span><span class=3D"styled-by-prettify"><font color=3D"#000000">)</font><=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>{</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=
<br>=C2=A0 =C2=A0 </span><span class=3D"styled-by-prettify" style=3D"color:=
rgb(136, 0, 0);">// found<br></span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">}</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 136);">else</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 =C2=A0 </span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">// not found</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</sp=
an></code></pre></code></pre></div></code></div><div style=3D"color: rgb(34=
, 34, 34); font-family: Arial, Helvetica, sans-serif; white-space: normal; =
background-color: rgb(255, 255, 255);"><br></div></span></div></code></div>=
</code></pre></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/b7cc5b96-2165-4b4d-a9d3-7ddec49ca626%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b7cc5b96-2165-4b4d-a9d3-7ddec49ca626=
%40isocpp.org</a>.<br />
------=_Part_5248_693864134.1501608140973--
------=_Part_5247_132522116.1501608140972--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 1 Aug 2017 20:26:12 +0300
Raw View
On 1 August 2017 at 20:22, <david.bolvansky@gmail.com> wrote:
> Instead of comparing with end(), there could be a new function - contains.
>
> Now
>
> if(std::find(vector.begin(), vector.end(), item) != vector.end()){
> // found
> } else {
> // not found
> }
>
> // maps
>
> if(map.find("key") != map.end()){
> // found
> } else {
> // not found
> }
>
>
>
> I propose "contains" function:
>
> if(std::contains(vector.begin(), vector.end(), item)){
> // found
> } else {
> // not found
> }
>
> // maps
>
> if(map.contains("key")){
> // found
> } else {
> // not found
> }
Just use std::count and map::count.
--
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/CAFk2RUbMLLU6-zfnyFk_%3DFyAYU%3DcNNMCb%3Dq6jijNf1Gr_FF%2BtQ%40mail.gmail.com.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 1 Aug 2017 20:29:22 +0300
Raw View
On 1 August 2017 at 20:26, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> On 1 August 2017 at 20:22, <david.bolvansky@gmail.com> wrote:
>> Instead of comparing with end(), there could be a new function - contains.
>>
>> Now
>>
>> if(std::find(vector.begin(), vector.end(), item) != vector.end()){
>> // found
>> } else {
>> // not found
>> }
>>
>> // maps
>>
>> if(map.find("key") != map.end()){
>> // found
>> } else {
>> // not found
>> }
>>
>>
>>
>> I propose "contains" function:
>>
>> if(std::contains(vector.begin(), vector.end(), item)){
>> // found
>> } else {
>> // not found
>> }
>>
>> // maps
>>
>> if(map.contains("key")){
>> // found
>> } else {
>> // not found
>> }
>
>
> Just use std::count and map::count.
...well, except that wastes cycles since it won't stop before the end
of the range for vector.
--
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/CAFk2RUaUTWj7xOz3aC-fDy754XYptA0U-SKtmSm%2Bqn9pcek_Dw%40mail.gmail.com.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 1 Aug 2017 20:31:36 +0300
Raw View
On 1 August 2017 at 20:29, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> On 1 August 2017 at 20:26, Ville Voutilainen
> <ville.voutilainen@gmail.com> wrote:
>> On 1 August 2017 at 20:22, <david.bolvansky@gmail.com> wrote:
>>> Instead of comparing with end(), there could be a new function - contains.
>>>
>>> Now
>>>
>>> if(std::find(vector.begin(), vector.end(), item) != vector.end()){
>>> // found
>>> } else {
>>> // not found
>>> }
>>>
>>> // maps
>>>
>>> if(map.find("key") != map.end()){
>>> // found
>>> } else {
>>> // not found
>>> }
>>>
>>>
>>>
>>> I propose "contains" function:
>>>
>>> if(std::contains(vector.begin(), vector.end(), item)){
>>> // found
>>> } else {
>>> // not found
>>> }
>>>
>>> // maps
>>>
>>> if(map.contains("key")){
>>> // found
>>> } else {
>>> // not found
>>> }
>>
>>
>> Just use std::count and map::count.
>
> ..well, except that wastes cycles since it won't stop before the end
> of the range for vector.
...which means that for vector, any_of is what you want. It's not named
'contains', and you'll just
have to live with it.
--
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/CAFk2RUZ8BFq-EEtoEa4hfBkyiTHBSEyYnHS8XrHAC_Rg0t%2Byhg%40mail.gmail.com.
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 1 Aug 2017 20:46:10 +0300
Raw View
On 1 August 2017 at 20:31, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
>>> Just use std::count and map::count.
>>
>> ..well, except that wastes cycles since it won't stop before the end
>> of the range for vector.
>
> ..which means that for vector, any_of is what you want. It's not named
> 'contains', and you'll just
> have to live with it.
...sigh, which doesn't have a value overload. I would think a contains
function would fare
better in Ranges than in the current standard library.
--
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/CAFk2RUaiuR_CqbpAXrNjc1%2Bfa01Y0H9nWQvhOvHV%3Dfv0_xZv4A%40mail.gmail.com.
.
Author: david.bolvansky@gmail.com
Date: Fri, 4 Aug 2017 08:05:21 -0700 (PDT)
Raw View
------=_Part_776_1737924525.1501859121361
Content-Type: text/plain; charset="UTF-8"
What should be done next?
Is this request noted by the team behind Ranges or a proposal paper should be written?
--
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/7528dc43-0ef7-414e-827e-a85e49260e44%40isocpp.org.
------=_Part_776_1737924525.1501859121361--
.
Author: "'Jeffrey Yasskin' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 4 Aug 2017 08:17:36 -0700
Raw View
--94eb2c1cb8187e46210555ef00b9
Content-Type: text/plain; charset="UTF-8"
On Tue, Aug 1, 2017 at 10:46 AM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:
> On 1 August 2017 at 20:31, Ville Voutilainen
> <ville.voutilainen@gmail.com> wrote:
> >>> Just use std::count and map::count.
> >>
> >> ..well, except that wastes cycles since it won't stop before the end
> >> of the range for vector.
> >
> > ..which means that for vector, any_of is what you want. It's not named
> > 'contains', and you'll just
> > have to live with it.
>
> ..sigh, which doesn't have a value overload. I would think a contains
> function would fare
> better in Ranges than in the current standard library.
>
:) We got a paper for adding contains() to containers in Toronto:
https://wg21.link/P0458
--
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/CANh-dXnsCzCDANQevWh%3Dj-AZ%2BGciyWxuKomu8GBsA7V72_VUag%40mail.gmail.com.
--94eb2c1cb8187e46210555ef00b9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
ue, Aug 1, 2017 at 10:46 AM, Ville Voutilainen <span dir=3D"ltr"><<a hre=
f=3D"mailto:ville.voutilainen@gmail.com" target=3D"_blank" class=3D"gmail-c=
remed cremed">ville.voutilainen@gmail.com</a>></span> wrote:<br><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px=
solid rgb(204,204,204);padding-left:1ex">On 1 August 2017 at 20:31, Ville =
Voutilainen<br>
<span class=3D"gmail-"><<a href=3D"mailto:ville.voutilainen@gmail.com" c=
lass=3D"gmail-cremed cremed">ville.voutilainen@gmail.com</a>> wrote:<br>
>>> Just use std::count and map::count.<br>
>><br>
>> ..well, except that wastes cycles since it won't stop before t=
he end<br>
>> of the range for vector.<br>
><br>
> ..which means that for vector, any_of is what you want. It's not n=
amed<br>
> 'contains', and you'll just<br>
> have to live with it.<br>
<br>
</span>..sigh, which doesn't have a value overload. I would think a con=
tains<br>
function would fare<br>
better in Ranges than in the current standard library.<br></blockquote><div=
><br></div></div></div><div class=3D"gmail_extra">:) We got a paper for add=
ing contains() to containers in Toronto: <a href=3D"https://wg21.link/P0458=
">https://wg21.link/P0458</a></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/CANh-dXnsCzCDANQevWh%3Dj-AZ%2BGciyWxu=
Komu8GBsA7V72_VUag%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANh-dXnsCzCD=
ANQevWh%3Dj-AZ%2BGciyWxuKomu8GBsA7V72_VUag%40mail.gmail.com</a>.<br />
--94eb2c1cb8187e46210555ef00b9--
.
Author: david.bolvansky@gmail.com
Date: Fri, 4 Aug 2017 08:19:31 -0700 (PDT)
Raw View
------=_Part_851_1279516203.1501859971241
Content-Type: text/plain; charset="UTF-8"
Awesome, thanks!
--
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/70516e50-ec33-4c7b-9304-41f1d2ae2cb6%40isocpp.org.
------=_Part_851_1279516203.1501859971241--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 4 Aug 2017 10:21:46 -0700 (PDT)
Raw View
------=_Part_973_2054977490.1501867307044
Content-Type: multipart/alternative;
boundary="----=_Part_974_2044012708.1501867307044"
------=_Part_974_2044012708.1501867307044
Content-Type: text/plain; charset="UTF-8"
On Friday, August 4, 2017 at 11:18:00 AM UTC-4, Jeffrey Yasskin wrote:
>
> On Tue, Aug 1, 2017 at 10:46 AM, Ville Voutilainen <ville.vo...@gmail.com
> <javascript:>> wrote:
>
>> On 1 August 2017 at 20:31, Ville Voutilainen
>> <ville.vo...@gmail.com <javascript:>> wrote:
>> >>> Just use std::count and map::count.
>> >>
>> >> ..well, except that wastes cycles since it won't stop before the end
>> >> of the range for vector.
>> >
>> > ..which means that for vector, any_of is what you want. It's not named
>> > 'contains', and you'll just
>> > have to live with it.
>>
>> ..sigh, which doesn't have a value overload. I would think a contains
>> function would fare
>> better in Ranges than in the current standard library.
>>
>
> :) We got a paper for adding contains() to containers in Toronto:
> https://wg21.link/P0458
>
That's only for associative containers, though. There's no equivalent to
the `std::find` algorithm.
--
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/2db819ca-be2a-4ad9-a33a-1a74cfccc0f0%40isocpp.org.
------=_Part_974_2044012708.1501867307044
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Friday, August 4, 2017 at 11:18:00 AM UTC-4, Je=
ffrey Yasskin wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><div><div class=3D"gmail_quote">On Tue, Aug 1, 2017 at 10:46 AM, V=
ille Voutilainen <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_b=
lank" gdf-obfuscated-mailto=3D"y2feIiJrBgAJ" rel=3D"nofollow" onmousedown=
=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D=
'javascript:';return true;">ville.vo...@gmail.com</a>></span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 1 August 2017 =
at 20:31, Ville Voutilainen<br>
<span><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"y2feIiJrBgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascri=
pt:';return true;" onclick=3D"this.href=3D'javascript:';return =
true;">ville.vo...@gmail.com</a>> wrote:<br>
>>> Just use std::count and map::count.<br>
>><br>
>> ..well, except that wastes cycles since it won't stop before t=
he end<br>
>> of the range for vector.<br>
><br>
> ..which means that for vector, any_of is what you want. It's not n=
amed<br>
> 'contains', and you'll just<br>
> have to live with it.<br>
<br>
</span>..sigh, which doesn't have a value overload. I would think a con=
tains<br>
function would fare<br>
better in Ranges than in the current standard library.<br></blockquote><div=
><br></div></div></div><div>:) We got a paper for adding contains() to cont=
ainers in Toronto: <a href=3D"https://wg21.link/P0458" target=3D"_blank" re=
l=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.com/url?q=
\x3dhttps%3A%2F%2Fwg21.link%2FP0458\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NGJkFi42vzzRnb_ZeZ99FPXNS_BCA';return true;" onclick=3D"this.href=3D=
9;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwg21.link%2FP0458\x26sa\x3d=
D\x26sntz\x3d1\x26usg\x3dAFQjCNGJkFi42vzzRnb_ZeZ99FPXNS_BCA';return tru=
e;">https://wg21.link/P0458</a></div></div></blockquote><div><br>That's=
only for associative containers, though. There's no equivalent to the =
`std::find` algorithm.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/2db819ca-be2a-4ad9-a33a-1a74cfccc0f0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2db819ca-be2a-4ad9-a33a-1a74cfccc0f0=
%40isocpp.org</a>.<br />
------=_Part_974_2044012708.1501867307044--
------=_Part_973_2054977490.1501867307044--
.
Author: david.bolvansky@gmail.com
Date: Sat, 5 Aug 2017 07:48:11 -0700 (PDT)
Raw View
------=_Part_1734_870533197.1501944491971
Content-Type: text/plain; charset="UTF-8"
We should write a paper to propose "contains" into algoritm and Ranges, right?
--
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/82cdb631-00e7-43d7-849d-c0bb34f0fab7%40isocpp.org.
------=_Part_1734_870533197.1501944491971--
.
Author: olafvdspek@gmail.com
Date: Wed, 9 Aug 2017 02:54:00 -0700 (PDT)
Raw View
------=_Part_5231_1450489714.1502272440377
Content-Type: multipart/alternative;
boundary="----=_Part_5232_1465201819.1502272440377"
------=_Part_5232_1465201819.1502272440377
Content-Type: text/plain; charset="UTF-8"
Op vrijdag 4 augustus 2017 19:21:49 UTC+2 schreef Nicol Bolas:
>
>
> That's only for associative containers, though. There's no equivalent to
> the `std::find` algorithm.
>
I think associative containers are the most common use case, so is that
bad?
--
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/41057f60-9484-446a-8dc8-183915ddaf07%40isocpp.org.
------=_Part_5232_1465201819.1502272440377
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Op vrijdag 4 augustus 2017 19:21:49 UTC+2 schreef Nicol Bo=
las:<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><br>=
That's only for associative containers, though. There's no equivale=
nt to the `std::find` algorithm.<br></div></div></blockquote><div><br></div=
><div>I think =C2=A0associative containers are the most common use case, so=
is that bad?</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/41057f60-9484-446a-8dc8-183915ddaf07%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/41057f60-9484-446a-8dc8-183915ddaf07=
%40isocpp.org</a>.<br />
------=_Part_5232_1465201819.1502272440377--
------=_Part_5231_1450489714.1502272440377--
.
Author: the.ultimate.koala@gmail.com
Date: Fri, 25 Aug 2017 06:10:38 -0700 (PDT)
Raw View
------=_Part_2612_857397422.1503666638998
Content-Type: multipart/alternative;
boundary="----=_Part_2613_1452310044.1503666638998"
------=_Part_2613_1452310044.1503666638998
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Le mardi 1 ao=C3=BBt 2017 19:46:13 UTC+2, Ville Voutilainen a =C3=A9crit :
>
> On 1 August 2017 at 20:31, Ville Voutilainen=20
> <ville.vo...@gmail.com <javascript:>> wrote:=20
> >>> Just use std::count and map::count.=20
> >>=20
> >> ..well, except that wastes cycles since it won't stop before the end=
=20
> >> of the range for vector.=20
> >=20
> > ..which means that for vector, any_of is what you want. It's not named=
=20
> > 'contains', and you'll just=20
> > have to live with it.=20
>
> ..sigh, which doesn't have a value overload. I would think a contains=20
> function would fare=20
> better in Ranges than in the current standard library.=20
>
Well, any_of with a value overload would surely do on any old vector, but=
=20
if you have the guarantee that your vector is sorted in a meaningful way=20
with regards to the sought out value, std::equal_range would be better=20
suited than linear search.
--=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/9322e593-ba08-46ec-947b-810e17bdc6d9%40isocpp.or=
g.
------=_Part_2613_1452310044.1503666638998
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>Le mardi 1 ao=C3=BBt 2017 19:46:13 UTC+2, Ville Vo=
utilainen a =C3=A9crit=C2=A0:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">O=
n 1 August 2017 at 20:31, Ville Voutilainen
<br><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
nSL0IKbUBAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">ville.vo...@gmail.com</a>> wrote:
<br>>>> Just use std::count and map::count.
<br>>>
<br>>> ..well, except that wastes cycles since it won't stop befo=
re the end
<br>>> of the range for vector.
<br>>
<br>> ..which means that for vector, any_of is what you want. It's n=
ot named
<br>> 'contains', and you'll just
<br>> have to live with it.
<br>
<br>..sigh, which doesn't have a value overload. I would think a contai=
ns
<br>function would fare
<br>better in Ranges than in the current standard library.
<br></blockquote><div><br>Well, any_of with a value overload would surely d=
o on any old vector, but if you have the guarantee that your vector is sort=
ed in a meaningful way with regards to the sought out value, std::equal_ran=
ge would be better suited than linear search.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/9322e593-ba08-46ec-947b-810e17bdc6d9%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9322e593-ba08-46ec-947b-810e17bdc6d9=
%40isocpp.org</a>.<br />
------=_Part_2613_1452310044.1503666638998--
------=_Part_2612_857397422.1503666638998--
.