Topic: count_while" and "count_until" algorithms
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Tue, 8 Oct 2013 22:04:23 +0200
Raw View
--e89a8f502fead519f604e84048bd
Content-Type: text/plain; charset=ISO-8859-1
Hi,
I thought about two new algorithms, that could be named "count_while" and
"count_until". Here are their behavior:
template <class InputIterator, class UnaryPredicate>
typename iterator_traits<InputIterator>::difference_type
count_while (InputIterator first, InputIterator last, UnaryPredicate pred)
{
typename iterator_traits<InputIterator>::difference_type ret = 0;
while (first!=last && pred(*first)) {
++ret;
++first;
}
return ret;
}
template <class InputIterator, class UnaryPredicate>
typename iterator_traits<InputIterator>::difference_type
count_until (InputIterator first, InputIterator last, UnaryPredicate pred)
{
typename iterator_traits<InputIterator>::difference_type ret = 0;
while (first!=last && !pred(*first)) {
++ret;
++first;
}
return ret;
}
What do you think about adding these two components to the algorithms
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--e89a8f502fead519f604e84048bd
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div class=3D"" style=3D"background-color:rgb(250,250,25=
0);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-w=
rap:break-word">
<code class=3D""><div class=3D""><pre><code><var><span style=3D"color:rgb(0=
,0,136)" class=3D"">template</span></var><span style=3D"color:rgb(0,0,0)" c=
lass=3D""> </span><span style=3D"color:rgb(102,102,0)" class=3D""><</spa=
n><var><span style=3D"color:rgb(0,0,136)" class=3D"">class</span></var><spa=
n style=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(10=
2,0,102)" class=3D"">InputIterator</span><span style=3D"color:rgb(102,102,0=
)" class=3D"">,</span><span style=3D"color:rgb(0,0,0)" class=3D""> </span><=
var><span style=3D"color:rgb(0,0,136)" class=3D"">class</span></var><span s=
tyle=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(102,0=
,102)" class=3D"">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)"=
class=3D"">></span><span style=3D"color:rgb(0,0,0)" class=3D""><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)" class=3D"">typename</spa=
n></var><span style=3D"color:rgb(0,0,0)" class=3D""> iterator_traits</span>=
<span style=3D"color:rgb(102,102,0)" class=3D""><</span><span style=3D"c=
olor:rgb(102,0,102)" class=3D"">InputIterator</span><span style=3D"color:rg=
b(102,102,0)" class=3D"">>::</span><span style=3D"color:rgb(0,0,0)" clas=
s=3D"">difference_type<br>
=A0 =A0 count_while </span><span style=3D"color:rgb(102,102,0)" class=3D"">=
(</span><span style=3D"color:rgb(102,0,102)" class=3D"">InputIterator</span=
><span style=3D"color:rgb(0,0,0)" class=3D""> first</span><span style=3D"co=
lor:rgb(102,102,0)" class=3D"">,</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D""> </span><span style=3D"color:rgb(102,0,102)" class=3D"">InputIterat=
or</span><span style=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D=
"color:rgb(0,0,136)" class=3D"">last</span><span style=3D"color:rgb(102,102=
,0)" class=3D"">,</span><span style=3D"color:rgb(0,0,0)" class=3D""> </span=
><span style=3D"color:rgb(102,0,102)" class=3D"">UnaryPredicate</span><span=
style=3D"color:rgb(0,0,0)" class=3D""> pred</span><span style=3D"color:rgb=
(102,102,0)" class=3D"">)</span><span style=3D"color:rgb(0,0,0)" class=3D""=
><br>
</span><span style=3D"color:rgb(102,102,0)" class=3D"">{</span><span style=
=3D"color:rgb(0,0,0)" class=3D""><br>=A0 </span><var><span style=3D"color:r=
gb(0,0,136)" class=3D"">typename</span></var><span style=3D"color:rgb(0,0,0=
)" class=3D""> iterator_traits</span><span style=3D"color:rgb(102,102,0)" c=
lass=3D""><</span><span style=3D"color:rgb(102,0,102)" class=3D"">InputI=
terator</span><span style=3D"color:rgb(102,102,0)" class=3D"">>::</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"">difference_type ret </span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"">=3D</span><span style=3D"color:=
rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(0,102,102)" class=
=3D"">0</span><span style=3D"color:rgb(102,102,0)" class=3D"">;</span><span=
style=3D"color:rgb(0,0,0)" class=3D""><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)" class=3D"">while</span><=
/var><span style=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"col=
or:rgb(102,102,0)" class=3D"">(</span><span style=3D"color:rgb(0,0,0)" clas=
s=3D"">first</span><span style=3D"color:rgb(102,102,0)" class=3D"">!=3D</sp=
an><span style=3D"color:rgb(0,0,136)" class=3D"">last</span><var><span styl=
e=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(102,102,=
0)" class=3D"">&&</span><span style=3D"color:rgb(0,0,0)" class=3D""=
> </span></var><var></var><span style=3D"color:rgb(0,0,0)" class=3D"">pred<=
/span><span style=3D"color:rgb(102,102,0)" class=3D"">(*</span><span style=
=3D"color:rgb(0,0,0)" class=3D"">first</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"">))</span><span style=3D"color:rgb(0,0,0)" class=3D""> </s=
pan><span style=3D"color:rgb(102,102,0)" class=3D"">{</span><span style=3D"=
color:rgb(0,0,0)" class=3D""><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"">++</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"">ret</span><span style=3D"color:rgb=
(102,102,0)" class=3D"">;</span><span style=3D"color:rgb(0,0,0)" class=3D""=
><br>=A0 =A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"">++</spa=
n><span style=3D"color:rgb(0,0,0)" class=3D"">first</span><span style=3D"co=
lor:rgb(102,102,0)" class=3D"">;</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D""><br>
=A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"">}</span><span st=
yle=3D"color:rgb(0,0,0)" class=3D""><br>=A0 </span><var><span style=3D"colo=
r:rgb(0,0,136)" class=3D"">return</span></var><span style=3D"color:rgb(0,0,=
0)" class=3D""> ret</span><span style=3D"color:rgb(102,102,0)" class=3D"">;=
</span><span style=3D"color:rgb(0,0,0)" class=3D""><br>
</span><span style=3D"color:rgb(102,102,0)" class=3D"">}</span></code></pre=
></div></code></div><br><div class=3D"" style=3D"background-color:rgb(250,2=
50,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;w=
ord-wrap:break-word">
<code class=3D""><div class=3D""><pre><code><var><span style=3D"color:rgb(0=
,0,136)" class=3D"">template</span></var><span style=3D"color:rgb(0,0,0)" c=
lass=3D""> </span><span style=3D"color:rgb(102,102,0)" class=3D""><</spa=
n><var><span style=3D"color:rgb(0,0,136)" class=3D"">class</span></var><spa=
n style=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(10=
2,0,102)" class=3D"">InputIterator</span><span style=3D"color:rgb(102,102,0=
)" class=3D"">,</span><span style=3D"color:rgb(0,0,0)" class=3D""> </span><=
var><span style=3D"color:rgb(0,0,136)" class=3D"">class</span></var><span s=
tyle=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(102,0=
,102)" class=3D"">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)"=
class=3D"">></span><span style=3D"color:rgb(0,0,0)" class=3D""><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)" class=3D"">typename</spa=
n></var><span style=3D"color:rgb(0,0,0)" class=3D""> iterator_traits</span>=
<span style=3D"color:rgb(102,102,0)" class=3D""><</span><span style=3D"c=
olor:rgb(102,0,102)" class=3D"">InputIterator</span><span style=3D"color:rg=
b(102,102,0)" class=3D"">>::</span><span style=3D"color:rgb(0,0,0)" clas=
s=3D"">difference_type<br>
=A0 =A0 count_until </span><span style=3D"color:rgb(102,102,0)" class=3D"">=
(</span><span style=3D"color:rgb(102,0,102)" class=3D"">InputIterator</span=
><span style=3D"color:rgb(0,0,0)" class=3D""> first</span><span style=3D"co=
lor:rgb(102,102,0)" class=3D"">,</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D""> </span><span style=3D"color:rgb(102,0,102)" class=3D"">InputIterat=
or</span><span style=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D=
"color:rgb(0,0,136)" class=3D"">last</span><span style=3D"color:rgb(102,102=
,0)" class=3D"">,</span><span style=3D"color:rgb(0,0,0)" class=3D""> </span=
><span style=3D"color:rgb(102,0,102)" class=3D"">UnaryPredicate</span><span=
style=3D"color:rgb(0,0,0)" class=3D""> pred</span><span style=3D"color:rgb=
(102,102,0)" class=3D"">)</span><span style=3D"color:rgb(0,0,0)" class=3D""=
><br>
</span><span style=3D"color:rgb(102,102,0)" class=3D"">{</span><span style=
=3D"color:rgb(0,0,0)" class=3D""><br><code class=3D""><pre><code><span styl=
e=3D"color:rgb(0,0,0)" class=3D"">=A0 </span><var><span style=3D"color:rgb(=
0,0,136)" class=3D"">typename</span></var><span style=3D"color:rgb(0,0,0)" =
class=3D""> iterator_traits</span><span style=3D"color:rgb(102,102,0)" clas=
s=3D""><</span><span style=3D"color:rgb(102,0,102)" class=3D"">InputIter=
ator</span><span style=3D"color:rgb(102,102,0)" class=3D"">>::</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"">difference_type ret </span><span s=
tyle=3D"color:rgb(102,102,0)" class=3D"">=3D</span><span style=3D"color:rgb=
(0,0,0)" class=3D""> </span><span style=3D"color:rgb(0,102,102)" class=3D""=
>0</span><span style=3D"color:rgb(102,102,0)" class=3D"">;</span><span styl=
e=3D"color:rgb(0,0,0)" class=3D""><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)" class=3D"">while</span><=
/var><span style=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"col=
or:rgb(102,102,0)" class=3D"">(</span><span style=3D"color:rgb(0,0,0)" clas=
s=3D"">first</span><span style=3D"color:rgb(102,102,0)" class=3D"">!=3D</sp=
an><span style=3D"color:rgb(0,0,136)" class=3D"">last</span><var><span styl=
e=3D"color:rgb(0,0,0)" class=3D""> </span><span style=3D"color:rgb(102,102,=
0)" class=3D"">&&</span><span style=3D"color:rgb(0,0,0)" class=3D""=
> </span></var><var></var><span style=3D"color:rgb(0,0,0)" class=3D"">!pred=
</span><span style=3D"color:rgb(102,102,0)" class=3D"">(*</span><span style=
=3D"color:rgb(0,0,0)" class=3D"">first</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"">))</span><span style=3D"color:rgb(0,0,0)" class=3D""> </s=
pan><span style=3D"color:rgb(102,102,0)" class=3D"">{</span><span style=3D"=
color:rgb(0,0,0)" class=3D""><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"">++</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"">ret</span><span style=3D"color:rgb=
(102,102,0)" class=3D"">;</span><span style=3D"color:rgb(0,0,0)" class=3D""=
><br>=A0 =A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"">++</spa=
n><span style=3D"color:rgb(0,0,0)" class=3D"">first</span><span style=3D"co=
lor:rgb(102,102,0)" class=3D"">;</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D""><br>
=A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"">}</span><span st=
yle=3D"color:rgb(0,0,0)" class=3D""><br>=A0 </span><var><span style=3D"colo=
r:rgb(0,0,136)" class=3D"">return</span></var><span style=3D"color:rgb(0,0,=
0)" class=3D""> ret;<br>
}</span><span style=3D"color:rgb(102,102,0)" class=3D""></span></code></pre=
></code></span></code><code><span style=3D"color:rgb(0,0,0)" class=3D""></s=
pan><span style=3D"color:rgb(102,102,0)" class=3D""></span></code></pre></d=
iv></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--e89a8f502fead519f604e84048bd--
.
Author: Philipp Stephani <p.stephani2@gmail.com>
Date: Tue, 8 Oct 2013 22:16:30 +0200
Raw View
--001a11c37ababadd5f04e840718e
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
I like the idea, they are simple and solve a generic problem that otherwise
requires a for loop (unless you have at least a forward iterator, then you
can use count_if + distance).
2013/10/8 R=E9my Lefevre <lefevreremy@gmail.com>
> Hi,
>
> I thought about two new algorithms, that could be named "count_while" and
> "count_until". Here are their behavior:
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_while (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
> }
>
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_until (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
>
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && !pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
>
> }
>
>
> What do you think about adding these two components to the algorithms
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--001a11c37ababadd5f04e840718e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I like the idea, they are simple and solve a generic probl=
em that otherwise requires a for loop (unless you have at least a forward i=
terator, then you can use count_if + distance).</div><div class=3D"gmail_ex=
tra">
<br><br><div class=3D"gmail_quote">2013/10/8 R=E9my Lefevre <span dir=3D"lt=
r"><<a href=3D"mailto:lefevreremy@gmail.com" target=3D"_blank">lefevrere=
my@gmail.com</a>></span><br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"background-color:rgb(250,250,250);border-c=
olor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-w=
ord">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style> </span><span style=3D"color:rgb(102,102,0)"><</span=
><var><span style=3D"color:rgb(0,0,136)">class</span></var><span style> </s=
pan><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style> </span><var><span style=3D"colo=
r:rgb(0,0,136)">class</span></var><span style> </span><span style=3D"color:=
rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)">&=
gt;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an style> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</=
span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=
=3D"color:rgb(102,102,0)">>::</span><span style>difference_type<br>
=A0 =A0 count_while </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span style> first</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style> </span><span =
style=3D"color:rgb(102,0,102)">InputIterator</span><span style> </span><spa=
n style=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style> </span><span style=3D"color:rgb(102,0,102)">UnaryP=
redicate</span><span style> pred</span><span style=3D"color:rgb(102,102,0)"=
>)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>=A0 </s=
pan><var><span style=3D"color:rgb(0,0,136)">typename</span></var><span styl=
e> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><s=
pan style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color=
:rgb(102,102,0)">>::</span><span style>difference_type ret </span><span =
style=3D"color:rgb(102,102,0)">=3D</span><span style> </span><span style=3D=
"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">;</span=
><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span =
style> </span><span style=3D"color:rgb(102,102,0)">(</span><span style>firs=
t</span><span style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"colo=
r:rgb(0,0,136)">last</span><var><span style> </span><span style=3D"color:rg=
b(102,102,0)">&&</span><span style> </span></var><var></var><span s=
tyle>pred</span><span style=3D"color:rgb(102,102,0)">(*</span><span style>f=
irst</span><span style=3D"color:rgb(102,102,0)">))</span><span style> </spa=
n><span style=3D"color:rgb(102,102,0)">{</span><span style><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>re=
t</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>=A0 =
=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>first<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br>=A0=
</span><var><span style=3D"color:rgb(0,0,136)">return</span></var><span st=
yle> ret</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br=
>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style> </span><span style=3D"color:rgb(102,102,0)"><</span=
><var><span style=3D"color:rgb(0,0,136)">class</span></var><span style> </s=
pan><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style> </span><var><span style=3D"colo=
r:rgb(0,0,136)">class</span></var><span style> </span><span style=3D"color:=
rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)">&=
gt;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an style> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</=
span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=
=3D"color:rgb(102,102,0)">>::</span><span style>difference_type<br>
=A0 =A0 count_until </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span style> first</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style> </span><span =
style=3D"color:rgb(102,0,102)">InputIterator</span><span style> </span><spa=
n style=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style> </span><span style=3D"color:rgb(102,0,102)">UnaryP=
redicate</span><span style> pred</span><span style=3D"color:rgb(102,102,0)"=
>)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br><code><=
pre><code><span style>=A0 </span><var><span style=3D"color:rgb(0,0,136)">ty=
pename</span></var><span style> iterator_traits</span><span style=3D"color:=
rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIterat=
or</span><span style=3D"color:rgb(102,102,0)">>::</span><span style>diff=
erence_type ret </span><span style=3D"color:rgb(102,102,0)">=3D</span><span=
style> </span><span style=3D"color:rgb(0,102,102)">0</span><span style=3D"=
color:rgb(102,102,0)">;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span =
style> </span><span style=3D"color:rgb(102,102,0)">(</span><span style>firs=
t</span><span style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"colo=
r:rgb(0,0,136)">last</span><var><span style> </span><span style=3D"color:rg=
b(102,102,0)">&&</span><span style> </span></var><var></var><span s=
tyle>!pred</span><span style=3D"color:rgb(102,102,0)">(*</span><span style>=
first</span><span style=3D"color:rgb(102,102,0)">))</span><span style> </sp=
an><span style=3D"color:rgb(102,102,0)">{</span><span style><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>re=
t</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>=A0 =
=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>first<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br>=A0=
</span><var><span style=3D"color:rgb(0,0,136)">return</span></var><span st=
yle> ret;<br>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span style></span><span style=3D"color:rgb(102,102,0)"></=
span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
=A0<br>
--- <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%2Bunsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11c37ababadd5f04e840718e--
.
Author: =?UTF-8?Q?R=C3=B3bert_D=C3=A1vid?= <lrdxgm@gmail.com>
Date: Tue, 8 Oct 2013 13:18:42 -0700 (PDT)
Raw View
------=_Part_543_9961887.1381263522712
Content-Type: text/plain; charset=ISO-8859-1
Isn't this the same as a find_if followed by substracting 'first'? (What
can be even faster than the proposed implementation for random access
iterators, if the substraction is cheaper than incrementing a number from 0
to the actual value.)
Probably still useful for "weaker" iterators.
Regard
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_543_9961887.1381263522712
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Isn't this the same as a find_if followed by substracting =
'first'? (What can be even faster than the proposed implementation for rand=
om access iterators, if the substraction is cheaper than incrementing a num=
ber from 0 to the actual value.)<br><br>Probably still useful for "weaker" =
iterators.<br><br>Regard<br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_543_9961887.1381263522712--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:26:47 -0700 (PDT)
Raw View
------=_Part_93_20220311.1381264007516
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Till now I do not see any great sense in introducing these algorithms. The=
=20
first algorithm is in fact equivalent to
=20
std::distance( first, std::find_if( first, last, std::not_equal_to<T>() ) )=
;
=20
The second algorithm is equivalent to
=20
std::distance( first, std::find_if( first, last, std::equal_to<T>() ) );
=20
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
> Hi,
>
> I thought about two new algorithms, that could be named "count_while" and=
=20
> "count_until". Here are their behavior:
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_while (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
> }
>
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_until (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
>
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && !pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
>
> }
>
>
> What do you think about adding these two components to the algorithms=20
> library ?
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_93_20220311.1381264007516
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Till now I do not see any great sense in introdu=
cing these algorithms. The first algorithm is in fact equivalent to</div><d=
iv> </div><div>std::distance( first, std::find_if( first, last, std::n=
ot_equal_to<T>() ) );</div><div> </div><div>The second algorithm=
is equivalent to</div><div> </div><div>std::distance( first, std::fin=
d_if( first, last, std::equal_to<T>() ) );</div><div> </div><div=
><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=
=D1=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=
=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(20=
4, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir=
=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could be named=
"count_while" and "count_until". Here are their behavior:<br><br><div styl=
e=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgroun=
d-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_while </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(0, 0, 13=
6);">typename</span></var><span style=3D"color: rgb(0, 0, 0);"> iterator_tr=
aits</span><span style=3D"color: rgb(102, 102, 0);"><</span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(102, 102, 0);">><wbr>::</span><span style=3D"color: rgb(0, 0, 0);">diff=
erence_type ret </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 10=
2, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=
=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0=
);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span></code></pre></div>=
</code></div><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_until </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br><code><pre><code><span style=3D"color: rgb(0, 0, 0);"=
> </span><var><span style=3D"color: rgb(0, 0, 136);">typename</span><=
/var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span styl=
e=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0,=
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><w=
br>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type ret </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">!pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span styl=
e=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, =
0);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret;<=
br>
}</span><span style=3D"color: rgb(102, 102, 0);"></span></code></pre></code=
></span></code><code><span style=3D"color: rgb(0, 0, 0);"></span><span styl=
e=3D"color: rgb(102, 102, 0);"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_93_20220311.1381264007516--
.
Author: Philipp Stephani <p.stephani2@gmail.com>
Date: Tue, 8 Oct 2013 22:26:53 +0200
Raw View
--001a11c373e6d8692304e84096f8
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
2013/10/8 R=F3bert D=E1vid <lrdxgm@gmail.com>
> Isn't this the same as a find_if followed by substracting 'first'?
>
>
You cannot do this subtraction for input iterators.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--001a11c373e6d8692304e84096f8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">2013/10/8 R=F3bert D=E1vid <span dir=3D"ltr"><<a href=3D"mailto:=
lrdxgm@gmail.com" target=3D"_blank">lrdxgm@gmail.com</a>></span><br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex">
<div dir=3D"ltr">Isn't this the same as a find_if followed by substract=
ing 'first'?</div><div dir=3D"ltr"><br></div></blockquote><div><br>=
</div><div>You cannot do this subtraction for input iterators.=A0</div></di=
v>
<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11c373e6d8692304e84096f8--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 13:27:10 -0700 (PDT)
Raw View
------=_Part_313_4331683.1381264030789
Content-Type: text/plain; charset=ISO-8859-1
I think to make it useful - both count and iterator should be returned.
Just think what happens when input range is single pass.
Plus, maybe special versions for RandomAccessIterator via compile time
dispatch (with better performance) .
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_313_4331683.1381264030789
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I think to make it useful - both count and iterator should=
be returned. Just think what happens when input range is single pass.<br>P=
lus, maybe special versions for RandomAccessIterator via compile time dispa=
tch (with better performance) .<br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_313_4331683.1381264030789--
.
Author: Philipp Stephani <p.stephani2@gmail.com>
Date: Tue, 8 Oct 2013 22:28:39 +0200
Raw View
--001a11c37a0832378904e8409dfa
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
That doesn't work if you can make only a single pass through the range.
2013/10/8 Vlad from Moscow <vlad.moscow@mail.ru>
> Till now I do not see any great sense in introducing these algorithms. Th=
e
> first algorithm is in fact equivalent to
>
> std::distance( first, std::find_if( first, last, std::not_equal_to<T>() )
> );
>
> The second algorithm is equivalent to
>
> std::distance( first, std::find_if( first, last, std::equal_to<T>() ) );
>
>
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>
>> Hi,
>>
>> I thought about two new algorithms, that could be named "count_while" an=
d
>> "count_until". Here are their behavior:
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>> typename iterator_traits<InputIterator>**::difference_type
>>
>>
>> count_while (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>> {
>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0;
>>
>>
>> while (first!=3Dlast && pred(*first)) {
>>
>>
>> ++ret;
>> ++first;
>>
>>
>> }
>> return ret;
>>
>> }
>>
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>> typename iterator_traits<InputIterator>**::difference_type
>>
>>
>> count_until (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>> {
>>
>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0;
>>
>>
>> while (first!=3Dlast && !pred(*first)) {
>>
>>
>> ++ret;
>> ++first;
>>
>>
>> }
>> return ret;
>>
>>
>> }
>>
>>
>> What do you think about adding these two components to the algorithms
>> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--001a11c37a0832378904e8409dfa
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That doesn't work if you can make only a single pass t=
hrough the range.<br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">2013/10/8 Vlad from Moscow <span dir=3D"ltr"><<a href=3D"mailto:=
vlad.moscow@mail.ru" target=3D"_blank">vlad.moscow@mail.ru</a>></span><b=
r>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Till now=C2=A0I do not=
see any great sense in introducing these algorithms. The first algorithm i=
s in fact equivalent to</div>
<div>=C2=A0</div><div>std::distance( first, std::find_if( first, last, std:=
:not_equal_to<T>() ) );</div><div>=C2=A0</div><div>The second algorit=
hm is equivalent to</div><div>=C2=A0</div><div>std::distance( first, std::f=
ind_if( first, last, std::equal_to<T>() ) );</div>
<div>=C2=A0</div><div><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=
=82=D1=8F=D0=B1=D1=80=D1=8F 2013=C2=A0=D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=
=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefe=
vre =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><div><div class=3D"h5"=
><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;paddin=
g-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-=
left-style:solid">
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"border:1px solid rgb(187,187,187);word-wra=
p:break-word;background-color:rgb(250,250,250)">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style> </span><span style=3D"color:rgb(102,102,0)"><</span=
><var><span style=3D"color:rgb(0,0,136)">class</span></var><span style> </s=
pan><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style> </span><var><span style=3D"colo=
r:rgb(0,0,136)">class</span></var><span style> </span><span style=3D"color:=
rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)">&=
gt;</span><span style><br>
=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var>=
<span style> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><=
;</span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span styl=
e=3D"color:rgb(102,102,0)">><u></u>::</span><span style>difference_type<=
br>
=C2=A0 =C2=A0 count_while </span><span style=3D"color:rgb(102,102,0)">(</sp=
an><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style> fi=
rst</span><span style=3D"color:rgb(102,102,0)">,</span><span style> </span>=
<span style=3D"color:rgb(102,0,102)">InputIterator</span><span style> </spa=
n><span style=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(10=
2,102,0)">,</span><span style> </span><span style=3D"color:rgb(102,0,102)">=
UnaryPredicate</span><span style> pred</span><span style=3D"color:rgb(102,1=
02,0)">)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>=C2=A0 =
</span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><span s=
tyle> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span=
><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"co=
lor:rgb(102,102,0)">><u></u>::</span><span style>difference_type ret </s=
pan><span style=3D"color:rgb(102,102,0)">=3D</span><span style> </span><spa=
n style=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0=
)">;</span><span style><br>
=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><sp=
an style> </span><span style=3D"color:rgb(102,102,0)">(</span><span style>f=
irst</span><span style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"c=
olor:rgb(0,0,136)">last</span><var><span style> </span><span style=3D"color=
:rgb(102,102,0)">&&</span><span style> </span></var><var></var><spa=
n style>pred</span><span style=3D"color:rgb(102,102,0)">(*</span><span styl=
e>first</span><span style=3D"color:rgb(102,102,0)">))</span><span style> </=
span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle>ret</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle>first</span><span style=3D"color:rgb(102,102,0)">;</span><span style><b=
r>
=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br>=
=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)">return</span></var><s=
pan style> ret</span><span style=3D"color:rgb(102,102,0)">;</span><span sty=
le><br>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"border:1px solid rgb(187,187,187);word-wrap:brea=
k-word;background-color:rgb(250,250,250)">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style> </span><span style=3D"color:rgb(102,102,0)"><</span=
><var><span style=3D"color:rgb(0,0,136)">class</span></var><span style> </s=
pan><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style> </span><var><span style=3D"colo=
r:rgb(0,0,136)">class</span></var><span style> </span><span style=3D"color:=
rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)">&=
gt;</span><span style><br>
=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var>=
<span style> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><=
;</span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span styl=
e=3D"color:rgb(102,102,0)">><u></u>::</span><span style>difference_type<=
br>
=C2=A0 =C2=A0 count_until </span><span style=3D"color:rgb(102,102,0)">(</sp=
an><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style> fi=
rst</span><span style=3D"color:rgb(102,102,0)">,</span><span style> </span>=
<span style=3D"color:rgb(102,0,102)">InputIterator</span><span style> </spa=
n><span style=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(10=
2,102,0)">,</span><span style> </span><span style=3D"color:rgb(102,0,102)">=
UnaryPredicate</span><span style> pred</span><span style=3D"color:rgb(102,1=
02,0)">)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br><code><=
pre><code><span style>=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)"=
>typename</span></var><span style> iterator_traits</span><span style=3D"col=
or:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIte=
rator</span><span style=3D"color:rgb(102,102,0)">><u></u>::</span><span =
style>difference_type ret </span><span style=3D"color:rgb(102,102,0)">=3D</=
span><span style> </span><span style=3D"color:rgb(0,102,102)">0</span><span=
style=3D"color:rgb(102,102,0)">;</span><span style><br>
=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><sp=
an style> </span><span style=3D"color:rgb(102,102,0)">(</span><span style>f=
irst</span><span style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"c=
olor:rgb(0,0,136)">last</span><var><span style> </span><span style=3D"color=
:rgb(102,102,0)">&&</span><span style> </span></var><var></var><spa=
n style>!pred</span><span style=3D"color:rgb(102,102,0)">(*</span><span sty=
le>first</span><span style=3D"color:rgb(102,102,0)">))</span><span style> <=
/span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle>ret</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>=
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle>first</span><span style=3D"color:rgb(102,102,0)">;</span><span style><b=
r>
=C2=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br>=
=C2=A0 </span><var><span style=3D"color:rgb(0,0,136)">return</span></var><s=
pan style> ret;<br>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span style></span><span style=3D"color:rgb(102,102,0)"></=
span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=C2=A0<br>
--- <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%2Bunsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11c37a0832378904e8409dfa--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:28:49 -0700 (PDT)
Raw View
------=_Part_74_30897740.1381264129783
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Though maybe I am mistaken because the equivalent code does not work for=20
iterators that have std::input_iterator_tag.
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:26:47 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
> Till now I do not see any great sense in introducing these algorithms. Th=
e=20
> first algorithm is in fact equivalent to
> =20
> std::distance( first, std::find_if( first, last, std::not_equal_to<T>() )=
=20
> );
> =20
> The second algorithm is equivalent to
> =20
> std::distance( first, std::find_if( first, last, std::equal_to<T>() ) );
> =20
>
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>
>> Hi,
>>
>> I thought about two new algorithms, that could be named "count_while" an=
d=20
>> "count_until". Here are their behavior:
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>> typename iterator_traits<InputIterator>::difference_type
>>
>>
>> count_while (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>> {
>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>
>>
>> while (first!=3Dlast && pred(*first)) {
>>
>>
>> ++ret;
>> ++first;
>>
>>
>> }
>> return ret;
>>
>> }
>>
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>> typename iterator_traits<InputIterator>::difference_type
>>
>>
>> count_until (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>> {
>>
>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>
>>
>> while (first!=3Dlast && !pred(*first)) {
>>
>>
>> ++ret;
>> ++first;
>>
>>
>> }
>> return ret;
>>
>>
>> }
>>
>>
>> What do you think about adding these two components to the algorithms=20
>> library ?
>>
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_74_30897740.1381264129783
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Though maybe I am mistaken because the equivalent cod=
e does not work for iterators that have std::input_iterator_tag.</div><div>=
<br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=
=D1=8F 2013 =D0=B3., 0:26:47 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 20=
4, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr=
"><div>Till now I do not see any great sense in introducing these algo=
rithms. The first algorithm is in fact equivalent to</div><div> </div>=
<div>std::distance( first, std::find_if( first, last, std::not_equal_to<=
T>() ) );</div><div> </div><div>The second algorithm is equivalent =
to</div><div> </div><div>std::distance( first, std::find_if( first, la=
st, std::equal_to<T>() ) );</div><div> </div><div><br>=D1=81=D1=
=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013&nb=
sp;=D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=
=D0=B0=D0=BB:</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0=
px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bor=
der-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr">Hi,<br><br=
>I thought about two new algorithms, that could be named "count_while" and =
"count_until". Here are their behavior:<br><br><div style=3D"border: 1px so=
lid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 2=
50, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_while </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(0, 0, 13=
6);">typename</span></var><span style=3D"color: rgb(0, 0, 0);"> iterator_tr=
aits</span><span style=3D"color: rgb(102, 102, 0);"><</span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(102, 102, 0);">><wbr>::</span><span style=3D"color: rgb(0, 0, 0);">diff=
erence_type ret </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 10=
2, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=
=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0=
);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span></code></pre></div>=
</code></div><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_until </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br><code><pre><code><span style=3D"color: rgb(0, 0, 0);"=
> </span><var><span style=3D"color: rgb(0, 0, 136);">typename</span><=
/var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span styl=
e=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0,=
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><w=
br>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type ret </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">!pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span styl=
e=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, =
0);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret;<=
br>
}</span><span style=3D"color: rgb(102, 102, 0);"></span></code></pre></code=
></span></code><code><span style=3D"color: rgb(0, 0, 0);"></span><span styl=
e=3D"color: rgb(102, 102, 0);"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_74_30897740.1381264129783--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:32:31 -0700 (PDT)
Raw View
------=_Part_515_29245385.1381264351813
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=20
[code]
In some thread here I proposed the similar idea for algorithm=20
std::accumulate.
template <class InputIterator, class T, class UnaryPredicate, class=20
BinaryOperation>
T accumulate_first_if( InputIterator first,=20
InputIterator last,
T init,
UnaryPredicate unary_predicate,
BinaryOperation binary_operation )
{
for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
{
init =3D binary_operation( init, *first );
}
return ( init );
}
[/code]
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
> Hi,
>
> I thought about two new algorithms, that could be named "count_while" and=
=20
> "count_until". Here are their behavior:
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_while (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
> }
>
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_until (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
>
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && !pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
>
> }
>
>
> What do you think about adding these two components to the algorithms=20
> library ?
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_515_29245385.1381264351813
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div> </div><div>[code]</div><div>In some thread here=
I proposed the similar idea for algorithm std::accumulate.</div><div>templ=
ate <class InputIterator, class T, class UnaryPredicate, class BinaryOpe=
ration><br>T accumulate_first_if( InputIterator first, <br> &=
nbsp; &nbs=
p; InputIterator last,<br> &=
nbsp; T init,<br> Una=
ryPredicate unary_predicate,<br> =
BinaryOperation binary_operation )<br>{<br> for ( ; first !=3D last &a=
mp;& unary_predicate( *first ) ; ++first )<br> {<br> in=
it =3D binary_operation( init, *first );<br> }</div><div> return =
( init );<br>}<br></div><div>[/code]<br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =
=D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., 0:04:23 UTC+4=
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=
=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquo=
te class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: =
1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-=
left-style: solid;"><div dir=3D"ltr">Hi,<br><br>I thought about two new alg=
orithms, that could be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); word=
-wrap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_while </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(0, 0, 13=
6);">typename</span></var><span style=3D"color: rgb(0, 0, 0);"> iterator_tr=
aits</span><span style=3D"color: rgb(102, 102, 0);"><</span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(102, 102, 0);">><wbr>::</span><span style=3D"color: rgb(0, 0, 0);">diff=
erence_type ret </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 10=
2, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=
=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0=
);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span></code></pre></div>=
</code></div><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_until </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br><code><pre><code><span style=3D"color: rgb(0, 0, 0);"=
> </span><var><span style=3D"color: rgb(0, 0, 136);">typename</span><=
/var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span styl=
e=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0,=
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><w=
br>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type ret </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">!pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span styl=
e=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, =
0);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret;<=
br>
}</span><span style=3D"color: rgb(102, 102, 0);"></span></code></pre></code=
></span></code><code><span style=3D"color: rgb(0, 0, 0);"></span><span styl=
e=3D"color: rgb(102, 102, 0);"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_515_29245385.1381264351813--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 13:32:35 -0700 (PDT)
Raw View
------=_Part_402_6554228.1381264355520
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =C7., 0:28:49 UTC+4 Vlad from Moscow:
>
> Though maybe I am mistaken because the equivalent code does not work for=
=20
> iterators that have std::input_iterator_tag.
>
>
Moreover, for forward and bidirectional iterators std::distance will not be=
=20
efficient approach.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_402_6554228.1381264355520
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =C7., 0:28:49 UTC+4 Vlad from Moscow:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Though maybe =
I am mistaken because the equivalent code does not work for iterators that =
have std::input_iterator_tag.</div><br></div></blockquote><div><br>Moreover=
, for forward and bidirectional iterators std::distance will not be effici=
ent approach.<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_402_6554228.1381264355520--
.
Author: lefevreremy@gmail.com
Date: Tue, 8 Oct 2013 13:33:18 -0700 (PDT)
Raw View
------=_Part_503_4340383.1381264398442
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Yes, the behavior is like find_if + distance, but the performance is better=
=20
(except maybe for random access iterator). I propose a template=20
specialization for random access iterator in order to be at least as fast=
=20
as find_if + distance.
Le mardi 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =E9crit :
>
> I think to make it useful - both count and iterator should be returned.=
=20
> Just think what happens when input range is single pass.
> Plus, maybe special versions for RandomAccessIterator via compile time=20
> dispatch (with better performance) .
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_503_4340383.1381264398442
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes, the behavior is like find_if + distance, but the perf=
ormance is better (except maybe for random access iterator). I propose a te=
mplate specialization for random access iterator in order to be at least as=
fast as find_if + distance.<br><br>Le mardi 8 octobre 2013 22:27:10 UTC+2,=
Evgeny Panasyuk a =E9crit :<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">I think to make it useful - both count and iterator sho=
uld be returned. Just think what happens when input range is single pass.<b=
r>Plus, maybe special versions for RandomAccessIterator via compile time di=
spatch (with better performance) .<br></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_503_4340383.1381264398442--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:35:01 -0700 (PDT)
Raw View
------=_Part_553_17807967.1381264501917
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Or the following definition
=20
[code]
template <class InputIterator, class T, class UnaryPredicate>
T accumulate_first_if( InputIterator first,=20
InputIterator last,
T init,
UnaryPredicate unary_predicate )
{
for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
{
init =3D ( T )( init + *first );
}
return ( init );
}
[/code]
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:32:31 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
> =20
> [code]
> In some thread here I proposed the similar idea for algorithm=20
> std::accumulate.
> template <class InputIterator, class T, class UnaryPredicate, class=20
> BinaryOperation>
> T accumulate_first_if( InputIterator first,=20
> InputIterator last,
> T init,
> UnaryPredicate unary_predicate,
> BinaryOperation binary_operation )
> {
> for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
> {
> init =3D binary_operation( init, *first );
> }
> return ( init );
> }
> [/code]
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>
>> Hi,
>>
>> I thought about two new algorithms, that could be named "count_while" an=
d=20
>> "count_until". Here are their behavior:
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>> typename iterator_traits<InputIterator>::difference_type
>>
>>
>> count_while (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>> {
>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>
>>
>> while (first!=3Dlast && pred(*first)) {
>>
>>
>> ++ret;
>> ++first;
>>
>>
>> }
>> return ret;
>>
>> }
>>
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>> typename iterator_traits<InputIterator>::difference_type
>>
>>
>> count_until (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>> {
>>
>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>
>>
>> while (first!=3Dlast && !pred(*first)) {
>>
>>
>> ++ret;
>> ++first;
>>
>>
>> }
>> return ret;
>>
>>
>> }
>>
>>
>> What do you think about adding these two components to the algorithms=20
>> library ?
>>
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_553_17807967.1381264501917
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Or the following definition</div><div> </div><di=
v>[code]</div><div>template <class InputIterator, class T, class UnaryPr=
edicate><br>T accumulate_first_if( InputIterator first, <br> =
&nb=
sp; InputIterator last,<br> =
T init,<br> Un=
aryPredicate unary_predicate )<br>{<br> for ( ; first !=3D last &&=
amp; unary_predicate( *first ) ; ++first )<br> {<br> init =
=3D ( T )( init + *first );<br> }</div><div> return ( init );<br>=
}<br></div><div>[/code]</div><div><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=
=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., 0:32:31 UTC+4 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vl=
ad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote=
class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1e=
x; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-le=
ft-style: solid;"><div dir=3D"ltr"><div> </div><div>[code]</div><div>I=
n some thread here I proposed the similar idea for algorithm std::accumulat=
e.</div><div>template <class InputIterator, class T, class UnaryPredicat=
e, class BinaryOperation><br>T accumulate_first_if( InputIterator first,=
<br> &nbs=
p; InputIterator last,<br> &=
nbsp; T init,<br> &nbs=
p; UnaryPredicate unary_predicate,<br> &=
nbsp; BinaryOperation binary_operation )<br>{<br> for ( ; =
first !=3D last && unary_predicate( *first ) ; ++first )<br> {=
<br> init =3D binary_operation( init, *first );<br> }</div>=
<div> return ( init );<br>}<br></div><div>[/code]<br>=D1=81=D1=80=D0=
=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=
=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=
=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=
=D0=BB:</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px=
0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-le=
ft-width: 1px; border-left-style: solid;"><div dir=3D"ltr">Hi,<br><br>I tho=
ught about two new algorithms, that could be named "count_while" and "count=
_until". Here are their behavior:<br><br><div style=3D"border: 1px solid rg=
b(187, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 25=
0);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_while </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(0, 0, 13=
6);">typename</span></var><span style=3D"color: rgb(0, 0, 0);"> iterator_tr=
aits</span><span style=3D"color: rgb(102, 102, 0);"><</span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(102, 102, 0);">><wbr>::</span><span style=3D"color: rgb(0, 0, 0);">diff=
erence_type ret </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 10=
2, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=
=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0=
);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span></code></pre></div>=
</code></div><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_until </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br><code><pre><code><span style=3D"color: rgb(0, 0, 0);"=
> </span><var><span style=3D"color: rgb(0, 0, 136);">typename</span><=
/var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span styl=
e=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0,=
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><w=
br>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type ret </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">!pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span styl=
e=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, =
0);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret;<=
br>
}</span><span style=3D"color: rgb(102, 102, 0);"></span></code></pre></code=
></span></code><code><span style=3D"color: rgb(0, 0, 0);"></span><span styl=
e=3D"color: rgb(102, 102, 0);"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_553_17807967.1381264501917--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 13:36:57 -0700 (PDT)
Raw View
------=_Part_885_7414682.1381264617980
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =D0=B3., 0:33:18 UTC+4 lefev...@gmail.com :
>
> Yes, the behavior is like find_if + distance, but the performance is=20
> better (except maybe for random access iterator). I propose a template=20
> specialization for random access iterator in order to be at least as fast=
=20
> as find_if + distance.
>
> Le mardi 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>>
>> I think to make it useful - both count and iterator should be returned.=
=20
>> Just think what happens when input range is single pass.
>> Plus, maybe special versions for RandomAccessIterator via compile time=
=20
>> dispatch (with better performance) .
>>
>
Just to clarify: do you see that both count and iterator should be returned=
?
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_885_7414682.1381264617980
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =D0=B3., 0:33:18 UTC+4 lefev...@gmail.com =
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Yes, the beh=
avior is like find_if + distance, but the performance is better (except may=
be for random access iterator). I propose a template specialization for ran=
dom access iterator in order to be at least as fast as find_if + distance.<=
br><br>Le mardi 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =C3=A9crit=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I think to =
make it useful - both count and iterator should be returned. Just think wha=
t happens when input range is single pass.<br>Plus, maybe special versions =
for RandomAccessIterator via compile time dispatch (with better performance=
) .<br></div></blockquote></div></blockquote><div><br><span id=3D"result_bo=
x" class=3D"short_text" lang=3D"en"><span class=3D"hps">Just to clarify</sp=
an></span>: do you see that both count and iterator should be returned?</d=
iv></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_885_7414682.1381264617980--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:37:13 -0700 (PDT)
Raw View
------=_Part_501_26566878.1381264633462
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
So I would propose name count_first_if instead of the both suggested=20
algorithms count_until and count_while.
=20
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:35:01 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
> Or the following definition
> =20
> [code]
> template <class InputIterator, class T, class UnaryPredicate>
> T accumulate_first_if( InputIterator first,=20
> InputIterator last,
> T init,
> UnaryPredicate unary_predicate )
> {
> for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
> {
> init =3D ( T )( init + *first );
> }
> return ( init );
> }
> [/code]
>
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:32:31 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
>> =20
>> [code]
>> In some thread here I proposed the similar idea for algorithm=20
>> std::accumulate.
>> template <class InputIterator, class T, class UnaryPredicate, class=20
>> BinaryOperation>
>> T accumulate_first_if( InputIterator first,=20
>> InputIterator last,
>> T init,
>> UnaryPredicate unary_predicate,
>> BinaryOperation binary_operation )
>> {
>> for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
>> {
>> init =3D binary_operation( init, *first );
>> }
>> return ( init );
>> }
>> [/code]
>> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=
=D1=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=
=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=
=B8=D1=81=D0=B0=D0=BB:
>>
>>> Hi,
>>>
>>> I thought about two new algorithms, that could be named "count_while"=
=20
>>> and "count_until". Here are their behavior:
>>>
>>> template <class InputIterator, class UnaryPredicate>
>>>
>>>
>>> typename iterator_traits<InputIterator>::difference_type
>>>
>>>
>>> count_while (InputIterator first, InputIterator last, UnaryPredicat=
e pred)
>>>
>>> {
>>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>>
>>>
>>> while (first!=3Dlast && pred(*first)) {
>>>
>>>
>>> ++ret;
>>> ++first;
>>>
>>>
>>> }
>>> return ret;
>>>
>>> }
>>>
>>>
>>> template <class InputIterator, class UnaryPredicate>
>>>
>>>
>>> typename iterator_traits<InputIterator>::difference_type
>>>
>>>
>>> count_until (InputIterator first, InputIterator last, UnaryPredicat=
e pred)
>>>
>>> {
>>>
>>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>>
>>>
>>> while (first!=3Dlast && !pred(*first)) {
>>>
>>>
>>> ++ret;
>>> ++first;
>>>
>>>
>>> }
>>> return ret;
>>>
>>>
>>> }
>>>
>>>
>>> What do you think about adding these two components to the algorithms=
=20
>>> library ?
>>>
>>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_501_26566878.1381264633462
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>So I would propose name count_first_if instead of the=
both suggested algorithms count_until and count_while.</div><div> </d=
iv><div><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=
=B1=D1=80=D1=8F 2013 =D0=B3., 0:35:01 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=
=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div d=
ir=3D"ltr"><div>Or the following definition</div><div> </div><div>[cod=
e]</div><div>template <class InputIterator, class T, class UnaryPredicat=
e><br>T accumulate_first_if( InputIterator first, <br> =
&nb=
sp; InputIterator last,<br> =
T init,<br> UnaryPre=
dicate unary_predicate )<br>{<br> for ( ; first !=3D last && u=
nary_predicate( *first ) ; ++first )<br> {<br> init =3D ( T=
)( init + *first );<br> }</div><div> return ( init );<br>}<br></=
div><div>[/code]</div><div><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=
=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., 0:32:31 UTC+4 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad fro=
m Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div dir=3D"ltr"><div> </div><div>[code]</div><div>In some=
thread here I proposed the similar idea for algorithm std::accumulate.</di=
v><div>template <class InputIterator, class T, class UnaryPredicate, cla=
ss BinaryOperation><br>T accumulate_first_if( InputIterator first, <br>&=
nbsp; &nbs=
p; InputIterator last,<br> &=
nbsp; T init,<br> &nbs=
p; UnaryPredicate unary_predicate,<br> &=
nbsp; BinaryOperation binary_operation )<br>{<br> for ( ; first =
!=3D last && unary_predicate( *first ) ; ++first )<br> {<br>&n=
bsp; init =3D binary_operation( init, *first );<br> }</div><div>&=
nbsp;return ( init );<br>}<br></div><div>[/code]<br>=D1=81=D1=80=D0=B5=D0=
=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., =
0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<=
/div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;"><div dir=3D"ltr">Hi,<br><br>I thought abo=
ut two new algorithms, that could be named "count_while" and "count_until".=
Here are their behavior:<br><br><div style=3D"border: 1px solid rgb(187, 1=
87, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_while </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(0, 0, 13=
6);">typename</span></var><span style=3D"color: rgb(0, 0, 0);"> iterator_tr=
aits</span><span style=3D"color: rgb(102, 102, 0);"><</span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(102, 102, 0);">><wbr>::</span><span style=3D"color: rgb(0, 0, 0);">diff=
erence_type ret </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 10=
2, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=
=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0=
);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span></code></pre></div>=
</code></div><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_until </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br><code><pre><code><span style=3D"color: rgb(0, 0, 0);"=
> </span><var><span style=3D"color: rgb(0, 0, 136);">typename</span><=
/var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span styl=
e=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0,=
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><w=
br>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type ret </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">!pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span styl=
e=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, =
0);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret;<=
br>
}</span><span style=3D"color: rgb(102, 102, 0);"></span></code></pre></code=
></span></code><code><span style=3D"color: rgb(0, 0, 0);"></span><span styl=
e=3D"color: rgb(102, 102, 0);"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div></blockquote></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_501_26566878.1381264633462--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 8 Oct 2013 15:36:43 -0500
Raw View
--047d7bdc093468486f04e840bcb2
Content-Type: text/plain; charset=ISO-8859-1
On 8 October 2013 15:33, <lefevreremy@gmail.com> wrote:
> Yes, the behavior is like find_if + distance, but the performance is
> better (except maybe for random access iterator). I propose a template
> specialization for random access iterator in order to be at least as fast
> as find_if + distance.
>
-1. You want to use overloading, not specializaton for iterator tags. I
am planning on writing up contiguous_iterator_tag for Issaquah, which is a
refinement of random access iterator, and would not perform as well if you
used specialization.
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7bdc093468486f04e840bcb2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 8 October 2013 15:33, <span dir=3D"ltr"><<a href=3D=
"mailto:lefevreremy@gmail.com" target=3D"_blank">lefevreremy@gmail.com</a>&=
gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=3D"gmail_quote">=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Yes, the behavior is like find_if + distance, but the perf=
ormance is better (except maybe for random access iterator). I propose a te=
mplate specialization for random access iterator in order to be at least as=
fast as find_if + distance.<br>
</div></blockquote><div><br></div><div>-1.=A0 You want to use overloading, =
not specializaton for iterator tags.=A0 I am planning on writing up contigu=
ous_iterator_tag for Issaquah, which is a refinement of random access itera=
tor, and would not perform as well if you used specialization.<br>
</div></div>-- <br>=A0Nevin ":-)" Liber=A0 <mailto:<a href=3D"=
mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>=
>=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bdc093468486f04e840bcb2--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:40:18 -0700 (PDT)
Raw View
------=_Part_551_5641249.1381264818642
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
As any negation of an unary predicate can be written as std::not1(=20
unary_predicate ) there is enough to propose only one algorithm namely with=
=20
name count_first_if.:)
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:37:13 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
> So I would propose name count_first_if instead of the both suggested=20
> algorithms count_until and count_while.
> =20
>
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:35:01 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
>> Or the following definition
>> =20
>> [code]
>> template <class InputIterator, class T, class UnaryPredicate>
>> T accumulate_first_if( InputIterator first,=20
>> InputIterator last,
>> T init,
>> UnaryPredicate unary_predicate )
>> {
>> for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
>> {
>> init =3D ( T )( init + *first );
>> }
>> return ( init );
>> }
>> [/code]
>>
>> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=
=D1=8F 2013 =D0=B3., 0:32:31 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=
=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Vlad from Moscow=20
>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>
>>> =20
>>> [code]
>>> In some thread here I proposed the similar idea for algorithm=20
>>> std::accumulate.
>>> template <class InputIterator, class T, class UnaryPredicate, class=20
>>> BinaryOperation>
>>> T accumulate_first_if( InputIterator first,=20
>>> InputIterator last,
>>> T init,
>>> UnaryPredicate unary_predicate,
>>> BinaryOperation binary_operation )
>>> {
>>> for ( ; first !=3D last && unary_predicate( *first ) ; ++first )
>>> {
>>> init =3D binary_operation( init, *first );
>>> }
>>> return ( init );
>>> }
>>> [/code]
>>> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=
=D1=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=
=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre=20
>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>>> Hi,
>>>>
>>>> I thought about two new algorithms, that could be named "count_while"=
=20
>>>> and "count_until". Here are their behavior:
>>>>
>>>> template <class InputIterator, class UnaryPredicate>
>>>>
>>>>
>>>> typename iterator_traits<InputIterator>::difference_type
>>>>
>>>>
>>>> count_while (InputIterator first, InputIterator last, UnaryPredica=
te pred)
>>>>
>>>> {
>>>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>>>
>>>>
>>>> while (first!=3Dlast && pred(*first)) {
>>>>
>>>>
>>>> ++ret;
>>>> ++first;
>>>>
>>>>
>>>> }
>>>> return ret;
>>>>
>>>> }
>>>>
>>>>
>>>> template <class InputIterator, class UnaryPredicate>
>>>>
>>>>
>>>> typename iterator_traits<InputIterator>::difference_type
>>>>
>>>>
>>>> count_until (InputIterator first, InputIterator last, UnaryPredica=
te pred)
>>>>
>>>> {
>>>>
>>>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>>>
>>>>
>>>> while (first!=3Dlast && !pred(*first)) {
>>>>
>>>>
>>>> ++ret;
>>>> ++first;
>>>>
>>>>
>>>> }
>>>> return ret;
>>>>
>>>>
>>>> }
>>>>
>>>>
>>>> What do you think about adding these two components to the algorithms=
=20
>>>> library ?
>>>>
>>>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_551_5641249.1381264818642
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>As any negation of an unary predicate can be written =
as std::not1( unary_predicate ) there is enough to propose only one algorit=
hm namely with name count_first_if.:)</div><div><br>=D1=81=D1=80=D0=B5=D0=
=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., =
0:37:13 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</=
div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
1px; border-left-style: solid;"><div dir=3D"ltr"><div>So I would propose n=
ame count_first_if instead of the both suggested algorithms count_until and=
count_while.</div><div> </div><div><br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0=
, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., 0:35:01 U=
TC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=
=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-le=
ft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bor=
der-left-style: solid;"><div dir=3D"ltr"><div>Or the following definition</=
div><div> </div><div>[code]</div><div>template <class InputIterator=
, class T, class UnaryPredicate><br>T accumulate_first_if( InputIterator=
first, <br> &nb=
sp; InputIterator last,<br>=
T init,<br> &nb=
sp; UnaryPredicate unary_predicate )<br>{<br> for ( =
; first !=3D last && unary_predicate( *first ) ; ++first )<br> =
;{<br> init =3D ( T )( init + *first );<br> }</div><div>&nb=
sp;return ( init );<br>}<br></div><div>[/code]</div><div><br>=D1=81=D1=80=
=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =
=D0=B3., 0:32:31 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=
=82=D0=B5=D0=BB=D1=8C Vlad from Moscow =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=
=D0=BB:</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px=
0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-le=
ft-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div> </div=
><div>[code]</div><div>In some thread here I proposed the similar idea for =
algorithm std::accumulate.</div><div>template <class InputIterator, clas=
s T, class UnaryPredicate, class BinaryOperation><br>T accumulate_first_=
if( InputIterator first, <br> &nbs=
p; InputI=
terator last,<br> T init,<br>&nbs=
p; UnaryPredicate unary_predicate,<br>&=
nbsp; BinaryOperation binary_operation =
)<br>{<br> for ( ; first !=3D last && unary_predicate( *first =
) ; ++first )<br> {<br> init =3D binary_operation( init, *f=
irst );<br> }</div><div> return ( init );<br>}<br></div><div>[/co=
de]<br>=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=
=80=D1=8F 2013 =D0=B3., 0:04:23 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=
=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(2=
04, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir=
=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could be named=
"count_while" and "count_until". Here are their behavior:<br><br><div styl=
e=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backgroun=
d-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_while </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(0, 0, 13=
6);">typename</span></var><span style=3D"color: rgb(0, 0, 0);"> iterator_tr=
aits</span><span style=3D"color: rgb(102, 102, 0);"><</span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(102, 102, 0);">><wbr>::</span><span style=3D"color: rgb(0, 0, 0);">diff=
erence_type ret </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 10=
2, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span style=
=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0=
);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"co=
lor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret</=
span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color:=
rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span></code></pre></div>=
</code></div><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);">
<code><div><pre><code><var><span style=3D"color: rgb(0, 0, 136);">template<=
/span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 102, 0);"><</span><var><span style=3D"color: rgb(0, 0, 136)=
;">class</span></var><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: r=
gb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><var=
><span style=3D"color: rgb(0, 0, 136);">class</span></var><span style=3D"co=
lor: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryP=
redicate</span><span style=3D"color: rgb(102, 102, 0);">></span><span st=
yle=3D"color: rgb(0, 0, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">typename</span></=
var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span style=
=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0, =
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><wb=
r>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type<br>
count_until </span><span style=3D"color: rgb(102, 102, 0);">(=
</span><span style=3D"color: rgb(102, 0, 102);">InputIterator</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> first</span><span style=3D"color: rgb(102, 1=
02, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 0, 102);">InputIterator</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">last</span><span=
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">UnaryPredicate</span=
><span style=3D"color: rgb(0, 0, 0);"> pred</span><span style=3D"color: rgb=
(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"colo=
r: rgb(0, 0, 0);"><br><code><pre><code><span style=3D"color: rgb(0, 0, 0);"=
> </span><var><span style=3D"color: rgb(0, 0, 136);">typename</span><=
/var><span style=3D"color: rgb(0, 0, 0);"> iterator_traits</span><span styl=
e=3D"color: rgb(102, 102, 0);"><</span><span style=3D"color: rgb(102, 0,=
102);">InputIterator</span><span style=3D"color: rgb(102, 102, 0);">><w=
br>::</span><span style=3D"color: rgb(0, 0, 0);">difference_type ret </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">0</span><spa=
n style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0=
, 0);"><br>
</span><var><span style=3D"color: rgb(0, 0, 136);">while</span></var=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">first</span><span =
style=3D"color: rgb(102, 102, 0);">!=3D</span><span style=3D"color: rgb(0, =
0, 136);">last</span><var><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">&&</span><span style=3D"color:=
rgb(0, 0, 0);"> </span></var><var></var><span style=3D"color: rgb(0, 0, 0)=
;">!pred</span><span style=3D"color: rgb(102, 102, 0);">(*</span><span styl=
e=3D"color: rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, =
0);">))</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">++</span><spa=
n style=3D"color: rgb(0, 0, 0);">ret</span><span style=3D"color: rgb(102, 1=
02, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br> </s=
pan><span style=3D"color: rgb(102, 102, 0);">++</span><span style=3D"color:=
rgb(0, 0, 0);">first</span><span style=3D"color: rgb(102, 102, 0);">;</spa=
n><span style=3D"color: rgb(0, 0, 0);"><br>
</span><span style=3D"color: rgb(102, 102, 0);">}</span><span style=
=3D"color: rgb(0, 0, 0);"><br> </span><var><span style=3D"color: rgb(=
0, 0, 136);">return</span></var><span style=3D"color: rgb(0, 0, 0);"> ret;<=
br>
}</span><span style=3D"color: rgb(102, 102, 0);"></span></code></pre></code=
></span></code><code><span style=3D"color: rgb(0, 0, 0);"></span><span styl=
e=3D"color: rgb(102, 102, 0);"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div></blockquote></div></blockquote></div></blockquote></div=
>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_551_5641249.1381264818642--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 8 Oct 2013 23:42:24 +0300
Raw View
--047d7bdc10185d5fc404e840cecd
Content-Type: text/plain; charset=ISO-8859-1
On 8 October 2013 23:40, Vlad from Moscow <vlad.moscow@mail.ru> wrote:
> As any negation of an unary predicate can be written as std::not1(
> unary_predicate ) there is enough to propose only one algorithm namely with
> name count_first_if.:)
>
>
>
not1 doesn't work with most predicates people are likely to write, which is
lambdas.
Then again, there's a proposal for a generic not_fn that doesn't require the
nested result_type.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7bdc10185d5fc404e840cecd
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 8 October 2013 23:40, Vlad from Moscow <span dir=3D"ltr"><<a =
href=3D"mailto:vlad.moscow@mail.ru" target=3D"_blank">vlad.moscow@mail.ru</=
a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>As any negation of an =
unary predicate can be written as std::not1( unary_predicate ) there is eno=
ugh to propose only one algorithm namely with name count_first_if.:)</div>
<div><br><br></div></div></blockquote><div><br></div><div>not1 doesn't =
work with most predicates people are likely to write, which is lambdas.<br>=
</div><div>Then again, there's a proposal for a generic not_fn that doe=
sn't require the<br>
nested result_type. <br></div></div><br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bdc10185d5fc404e840cecd--
.
Author: lefevreremy@gmail.com
Date: Tue, 8 Oct 2013 13:42:56 -0700 (PDT)
Raw View
------=_Part_869_8757290.1381264976956
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
@Evgeny: Yes, I see the advantage to return both count and iterator, but I=
=20
didn't find an elegant way to do it for the moment.
@Vlad: Why do you want to change the names?
Le mardi 8 octobre 2013 22:36:57 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>
> 9 oct 2013 =D0=B3., 0:33:18 UTC+4 lefev...@gmail.com :
>>
>> Yes, the behavior is like find_if + distance, but the performance is=20
>> better (except maybe for random access iterator). I propose a template=
=20
>> specialization for random access iterator in order to be at least as fas=
t=20
>> as find_if + distance.
>>
>> Le mardi 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>>>
>>> I think to make it useful - both count and iterator should be returned.=
=20
>>> Just think what happens when input range is single pass.
>>> Plus, maybe special versions for RandomAccessIterator via compile time=
=20
>>> dispatch (with better performance) .
>>>
>>
> Just to clarify: do you see that both count and iterator should be=20
> returned?
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_869_8757290.1381264976956
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span class=3D"_username"><span style=3D"color: rgb(34, 34=
, 34);" class=3D"GJHYW0UCLMB"></span></span>@Evgeny: Yes, I see the advanta=
ge to return both count and iterator, but I didn't find an elegant way to d=
o it for the moment.<br><br>@Vlad: Why do you want to change the names?<br>=
<br><br><br>Le mardi 8 octobre 2013 22:36:57 UTC+2, Evgeny Panasyuk a =C3=
=A9crit :<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
>9 oct 2013 =D0=B3., 0:33:18 UTC+4 <a>lefev...@gmail.com</a> :<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Yes, the behavior is like =
find_if + distance, but the performance is better (except maybe for random =
access iterator). I propose a template specialization for random access ite=
rator in order to be at least as fast as find_if + distance.<br><br>Le mard=
i 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =C3=A9crit :<blockq=
uote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I think to make it useful=
- both count and iterator should be returned. Just think what happens when=
input range is single pass.<br>Plus, maybe special versions for RandomAcce=
ssIterator via compile time dispatch (with better performance) .<br></div><=
/blockquote></div></blockquote><div><br><span lang=3D"en"><span>Just to cla=
rify</span></span>: do you see that both count and iterator should be retu=
rned?</div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_869_8757290.1381264976956--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 13:43:29 -0700 (PDT)
Raw View
------=_Part_904_28366259.1381265009423
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =D0=B3., 0:37:13 UTC+4 Vlad from Moscow:
>
> So I would propose name count_first_if instead of the both suggested=20
> algorithms count_until and count_while.
> =20
>
I think that count_until and count_while are better names than=20
count_first_if.
count_first_if is confusive, perhaps it implies count_until_first_if, but=
=20
plain count_until is just better.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_904_28366259.1381265009423
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =D0=B3., 0:37:13 UTC+4 Vlad from Moscow:<b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>So I would=
propose name count_first_if instead of the both suggested algorithms count=
_until and count_while.</div><div> </div></div></blockquote><div>I thi=
nk that count_until and count_while are better names than count_first_if.<b=
r>count_first_if is confusive, perhaps it <span id=3D"result_box" class=3D"=
short_text" lang=3D"en"><span class=3D"hps">implies</span></span> count_unt=
il_first_if, but plain count_until is just better.<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_904_28366259.1381265009423--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 8 Oct 2013 22:44:56 +0200
Raw View
2013/10/8 <lefevreremy@gmail.com>:
> @Evgeny: Yes, I see the advantage to return both count and iterator, but I
> didn't find an elegant way to do it for the moment.
Traditionally a std::pair<A, B> is used for this.
- Daniel
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 13:47:28 -0700 (PDT)
Raw View
------=_Part_921_33036132.1381265248306
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =C7., 0:42:56 UTC+4 lefev...@gmail.com:
>
> @Evgeny: Yes, I see the advantage to return both count and iterator, but =
I=20
> didn't find an elegant way to do it for the moment.
>
Alexander Stepanov used std::pair for that purpose at his "Efficient=20
Programming with Components" lectures -=20
http://www.youtube.com/watch?v=3DaIHAEYyoTUc&list=3DPLHxtyCq_WDLXryyw91lahw=
dtpZsmo4BGD=20
(by the way, these lectures are very inspirational).
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_921_33036132.1381265248306
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"> 9 oct 2013 =C7., 0:42:56 UTC+4 lefev...@gmail.c=
om:<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"><span><spa=
n style=3D"color:rgb(34,34,34)"></span></span>@Evgeny: Yes, I see the advan=
tage to return both count and iterator, but I didn't find an elegant way to=
do it for the moment.<br></div></blockquote><div><br>Alexander Stepanov us=
ed std::pair for that purpose at his "Efficient Programming with Components=
" lectures - http://www.youtube.com/watch?v=3DaIHAEYyoTUc&list=3DPLHxty=
Cq_WDLXryyw91lahwdtpZsmo4BGD (by the way, these lectures are very inspirati=
onal).<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_921_33036132.1381265248306--
.
Author: lefevreremy@gmail.com
Date: Tue, 8 Oct 2013 13:50:20 -0700 (PDT)
Raw View
------=_Part_315_7708016.1381265420537
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
That was I mentioned by inelegant way... I am not a big fan of std::pair.=
=20
But I should maybe change my mind on it.=20
Le mardi 8 octobre 2013 22:47:28 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>
> 9 oct 2013 =D0=B3., 0:42:56 UTC+4 lefev...@gmail.com:
>>
>> @Evgeny: Yes, I see the advantage to return both count and iterator, but=
=20
>> I didn't find an elegant way to do it for the moment.
>>
>
> Alexander Stepanov used std::pair for that purpose at his "Efficient=20
> Programming with Components" lectures -=20
> http://www.youtube.com/watch?v=3DaIHAEYyoTUc&list=3DPLHxtyCq_WDLXryyw91la=
hwdtpZsmo4BGD(by the way, these lectures are very inspirational).
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_315_7708016.1381265420537
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That was I mentioned by inelegant way... I am not a big fa=
n of std::pair. But I should maybe change my mind on it. <br><br>Le mardi 8=
octobre 2013 22:47:28 UTC+2, Evgeny Panasyuk a =C3=A9crit :<blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"> 9 oct 2013 =
=D0=B3., 0:42:56 UTC+4 <a>lefev...@gmail.com</a>:<blockquote class=3D"gmail=
_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr"><span><span style=3D"color:rgb(34,34,34)"></=
span></span>@Evgeny: Yes, I see the advantage to return both count and iter=
ator, but I didn't find an elegant way to do it for the moment.<br></div></=
blockquote><div><br>Alexander Stepanov used std::pair for that purpose at h=
is "Efficient Programming with Components" lectures - <a href=3D"http://www=
..youtube.com/watch?v=3DaIHAEYyoTUc&list=3DPLHxtyCq_WDLXryyw91lahwdtpZsm=
o4BGD" target=3D"_blank">http://www.youtube.com/watch?<wbr>v=3DaIHAEYyoTUc&=
amp;list=3DPLHxtyCq_<wbr>WDLXryyw91lahwdtpZsmo4BGD</a> (by the way, these l=
ectures are very inspirational).<br></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_315_7708016.1381265420537--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 8 Oct 2013 15:50:34 -0500
Raw View
--001a11337468f9be1f04e840ed73
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On 8 October 2013 15:44, Daniel Kr=FCgler <daniel.kruegler@gmail.com> wrote=
:
> 2013/10/8 <lefevreremy@gmail.com>:
> > @Evgeny: Yes, I see the advantage to return both count and iterator, bu=
t
> I
> > didn't find an elegant way to do it for the moment.
>
> Traditionally a std::pair<A, B> is used for this.
>
While true, I really rather we get away from doing so, as "iterator" and
"count" are far better field names than "first" and "second".
--=20
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--001a11337468f9be1f04e840ed73
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 8 October 2013 15:44, Daniel Kr=FCgler <span dir=3D"ltr=
"><<a href=3D"mailto:daniel.kruegler@gmail.com" target=3D"_blank">daniel=
..kruegler@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><di=
v class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">2013/10/8 =A0<<a href=3D"mailto:lefevrere=
my@gmail.com">lefevreremy@gmail.com</a>>:<br>
<div class=3D"im">> @Evgeny: Yes, I see the advantage to return both cou=
nt and iterator, but I<br>
> didn't find an elegant way to do it for the moment.<br>
<br>
</div>Traditionally a std::pair<A, B> is used for this.<br></blockquo=
te><div><br></div><div>While true, I really rather we get away from doing s=
o, as "iterator" and "count" are far better field names=
than "first" and "second".<br>
</div></div>-- <br>=A0Nevin ":-)" Liber=A0 <mailto:<a href=3D"=
mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>=
>=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11337468f9be1f04e840ed73--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 13:56:01 -0700 (PDT)
Raw View
------=_Part_321_28098160.1381265762012
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I want to change the name in the context of my proposal of=20
std::accumulate_first_if that there will be a common name for such types of=
=20
algorithms.
=20
By the way using std::find_if with a predicate resolves the two tasks:=20
returning the count and the last iterator.
=20
For example
=20
[code]
int a[] =3D { 1, 2, 3, 4, 0, 5 };
size_t n =3D 0;
std::find_if( std::begin( a ), std::end( a ),=20
[&]( int x ) { return ( !( x =3D=3D 0 ) ? ++n, false : true );=
} );
std::cout << n << std::endl;
[/code]
=20
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:42:56 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C lefev...@gmail.com=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
> @Evgeny: Yes, I see the advantage to return both count and iterator, but =
I=20
> didn't find an elegant way to do it for the moment.
>
> @Vlad: Why do you want to change the names?
>
>
>
> Le mardi 8 octobre 2013 22:36:57 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>>
>> 9 oct 2013 =D0=B3., 0:33:18 UTC+4 lefev...@gmail.com :
>>>
>>> Yes, the behavior is like find_if + distance, but the performance is=20
>>> better (except maybe for random access iterator). I propose a template=
=20
>>> specialization for random access iterator in order to be at least as fa=
st=20
>>> as find_if + distance.
>>>
>>> Le mardi 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>>>>
>>>> I think to make it useful - both count and iterator should be returned=
..=20
>>>> Just think what happens when input range is single pass.
>>>> Plus, maybe special versions for RandomAccessIterator via compile time=
=20
>>>> dispatch (with better performance) .
>>>>
>>>
>> Just to clarify: do you see that both count and iterator should be=20
>> returned?
>>
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_321_28098160.1381265762012
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I want to change the name in the context of my propos=
al of std::accumulate_first_if that there will be a common name for such ty=
pes of algorithms.</div><div> </div><div>By the way using std::find_if=
with a predicate resolves the two tasks: returning the count and the last =
iterator.</div><div> </div><div>For example</div><div> </div><div=
>[code]<br> int a[] =3D { 1, 2, 3, 4, 0, 5 };</div><div> &n=
bsp;size_t n =3D 0;</div><div> std::find_if( std::begin( a ), st=
d::end( a ), <br> &nbs=
p; [&]( int x ) { return ( !( x =3D=3D 0 ) ? ++n, false : t=
rue ); } );</div><div> std::cout << n << std::endl;<=
br> [/code]<br></div><div> </div><div><br>=D1=81=D1=80=D0=B5=D0=
=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013 =D0=B3., =
0:42:56 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C lefev...@gmail.com =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex;=
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-widt=
h: 1px; border-left-style: solid;"><div dir=3D"ltr"><span><span style=3D"co=
lor: rgb(34, 34, 34);"></span></span>@Evgeny: Yes, I see the advantage to r=
eturn both count and iterator, but I didn't find an elegant way to do it fo=
r the moment.<br><br>@Vlad: Why do you want to change the names?<br><br><br=
><br>Le mardi 8 octobre 2013 22:36:57 UTC+2, Evgeny Panasyuk a =C3=A9crit&n=
bsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;"><div dir=3D"ltr">9 oct 2013 =D0=B3.,=
0:33:18 UTC+4 <a>lefev...@gmail.com</a> :<blockquote class=3D"gmail_quote"=
style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: =
rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div=
dir=3D"ltr">Yes, the behavior is like find_if + distance, but the performa=
nce is better (except maybe for random access iterator). I propose a templa=
te specialization for random access iterator in order to be at least as fas=
t as find_if + distance.<br><br>Le mardi 8 octobre 2013 22:27:10 UTC+2, Evg=
eny Panasyuk a =C3=A9crit :<blockquote class=3D"gmail_quote" style=3D"=
margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 2=
04, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"lt=
r">I think to make it useful - both count and iterator should be returned. =
Just think what happens when input range is single pass.<br>Plus, maybe spe=
cial versions for RandomAccessIterator via compile time dispatch (with bett=
er performance) .<br></div></blockquote></div></blockquote><div><br><span l=
ang=3D"en"><span>Just to clarify</span></span>: do you see that both count=
and iterator should be returned?</div></div></blockquote></div></blockquot=
e></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_321_28098160.1381265762012--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 13:56:37 -0700 (PDT)
Raw View
------=_Part_375_18345402.1381265797761
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =D0=B3., 0:50:34 UTC+4 Nevin ":-)" Liber:
>
> On 8 October 2013 15:44, Daniel Kr=C3=BCgler <daniel....@gmail.com<javasc=
ript:>
> > wrote:
>
>> Traditionally a std::pair<A, B> is used for this.
>>
>
> While true, I really rather we get away from doing so, as "iterator" and=
=20
> "count" are far better field names than "first" and "second".
>
>
I agree. In my own code I just create new struct with good field names - it=
=20
is not a burden at all. And by the way, new struct is more "type-rich" way.
But I don't really sure about ISO - there is long history of returning=20
std::pair, like std::map::insert.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_375_18345402.1381265797761
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =D0=B3., 0:50:34 UTC+4 Nevin ":-)" Liber:<=
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">On 8 October 2=
013 15:44, Daniel Kr=C3=BCgler <span dir=3D"ltr"><<a href=3D"javascript:=
" target=3D"_blank" gdf-obfuscated-mailto=3D"rkOfYvH3gtEJ">daniel....@gmail=
..com</a>></span> wrote:<br><div><div class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Traditionally a std::pair<A, B> is use=
d for this.<br></blockquote><div><br></div><div>While true, I really rather=
we get away from doing so, as "iterator" and "count" are far better field =
names than "first" and "second".<br>
</div></div><br></div></div></blockquote><div><br>I agree. In my own code I=
just create new struct with good field names - it is not a burden at all. =
And by the way, new struct is more "type-rich" way.<br>But I don't really s=
ure about ISO - there is long history of returning std::pair, like std::map=
::insert.<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_375_18345402.1381265797761--
.
Author: lefevreremy@gmail.com
Date: Tue, 8 Oct 2013 13:59:17 -0700 (PDT)
Raw View
------=_Part_316_4162083.1381265957761
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
@Nevin: I agree for overload instead of specialization for random access=20
iterator. My bad !
Le mardi 8 octobre 2013 22:50:34 UTC+2, Nevin ":-)" Liber a =E9crit :
>
> On 8 October 2013 15:44, Daniel Kr=FCgler <daniel....@gmail.com<javascrip=
t:>
> > wrote:
>
>> 2013/10/8 <lefev...@gmail.com <javascript:>>:
>> > @Evgeny: Yes, I see the advantage to return both count and iterator,=
=20
>> but I
>> > didn't find an elegant way to do it for the moment.
>>
>> Traditionally a std::pair<A, B> is used for this.
>>
>
> While true, I really rather we get away from doing so, as "iterator" and=
=20
> "count" are far better field names than "first" and "second".
> --=20
> Nevin ":-)" Liber <mailto:ne...@eviloverlord.com <javascript:>> (847)=
=20
> 691-1404=20
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_316_4162083.1381265957761
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">@Nevin: I agree for overload instead of specialization for=
random access iterator. My bad !<br><br>Le mardi 8 octobre 2013 22:50:34 U=
TC+2, Nevin ":-)" Liber a =E9crit :<blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr">On 8 October 2013 15:44, Daniel Kr=FCgler <span =
dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-ma=
ilto=3D"rkOfYvH3gtEJ">daniel....@gmail.com</a>></span> wrote:<br><div><d=
iv class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">2013/10/8 <<a href=3D"javascript:" =
target=3D"_blank" gdf-obfuscated-mailto=3D"rkOfYvH3gtEJ">lefev...@gmail.com=
</a>>:<br>
<div>> @Evgeny: Yes, I see the advantage to return both count and iterat=
or, but I<br>
> didn't find an elegant way to do it for the moment.<br>
<br>
</div>Traditionally a std::pair<A, B> is used for this.<br></blockquo=
te><div><br></div><div>While true, I really rather we get away from doing s=
o, as "iterator" and "count" are far better field names than "first" and "s=
econd".<br>
</div></div>-- <br> Nevin ":-)" Liber <mailto:<a href=3D"java=
script:" target=3D"_blank" gdf-obfuscated-mailto=3D"rkOfYvH3gtEJ">ne...@evi=
loverlord.com</a><wbr>> (847) 691-1404
</div></div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_316_4162083.1381265957761--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 8 Oct 2013 23:00:37 +0200
Raw View
2013/10/8 Evgeny Panasyuk <evgeny.panasyuk@gmail.com>:
> Alexander Stepanov used std::pair for that purpose at his "Efficient
> Programming with Components" lectures
Actually the Library does this already at several occasions:
mismatch, partition_copy, equal_range, minmax, minmax_element,
get_temporary_buffer, ...
See also
http://cplusplus.github.io/LWG/lwg-active.html#2242
for another miss of useful information.
Unfortunately,
http://cplusplus.github.io/LWG/lwg-closed.html#1313
was declared NAD. I think I will re-raise it soon.
- Daniel
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 14:02:04 -0700 (PDT)
Raw View
------=_Part_561_28831654.1381266124987
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =C7., 0:56:01 UTC+4 Vlad from Moscow:
>
> I want to change the name in the context of my proposal of=20
> std::accumulate_first_if that there will be a common name for such types =
of=20
> algorithms.
>
Actually I think it is better to change name of accumulate_first_if to=20
accumulate_while.
=20
> By the way using std::find_if with a predicate resolves the two tasks:=20
> returning the count and the last iterator.
>
I think terse notation does matter.=20
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_561_28831654.1381266124987
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =C7., 0:56:01 UTC+4 Vlad from Moscow:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>I want to cha=
nge the name in the context of my proposal of std::accumulate_first_if that=
there will be a common name for such types of algorithms.</div></div></blo=
ckquote><div><br>Actually I think it is better to change name of accumulate=
_first_if to accumulate_while.<br> </div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;"><div dir=3D"ltr"><div>By the way using std::find_if with a =
predicate resolves the two tasks: returning the count and the last iterator=
..</div></div></blockquote><div><br>I think terse notation does matter. <br>=
</div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_561_28831654.1381266124987--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 14:08:50 -0700 (PDT)
Raw View
------=_Part_902_2570775.1381266530630
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
I would like to preserve the word "if" in such algorithms. We have for=20
example copy_if, count_if and so on. So we could include copy_first_if,=20
count_first_if and so on. It is a more consistent system of naming of=20
algorithms.
=D3=D2=C5=C4=C1, 9 =CF=CB=D4=D1=C2=D2=D1 2013 =C7., 1:02:04 UTC+4 =D0=CF=CC=
=D8=DA=CF=D7=C1=D4=C5=CC=D8 Evgeny Panasyuk=20
=CE=C1=D0=C9=D3=C1=CC:
> 9 oct 2013 =C7., 0:56:01 UTC+4 Vlad from Moscow:
>>
>> I want to change the name in the context of my proposal of=20
>> std::accumulate_first_if that there will be a common name for such types=
of=20
>> algorithms.
>>
>
> Actually I think it is better to change name of accumulate_first_if to=20
> accumulate_while.
> =20
>
>> By the way using std::find_if with a predicate resolves the two tasks:=
=20
>> returning the count and the last iterator.
>>
>
> I think terse notation does matter.=20
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_902_2570775.1381266530630
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I would like to preserve the word "if" in such algori=
thms. We have for example copy_if, count_if and so on. So we could include =
copy_first_if, count_first_if and so on. It is a more consistent system of =
naming of algorithms.</div><div><br>=D3=D2=C5=C4=C1, 9 =CF=CB=D4=D1=C2=D2=
=D1 2013 =C7., 1:02:04 UTC+4 =D0=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 Evge=
ny Panasyuk =CE=C1=D0=C9=D3=C1=CC:</div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div d=
ir=3D"ltr">9 oct 2013 =C7., 0:56:01 UTC+4 Vlad from Moscow:<blockquote=
class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1e=
x; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-le=
ft-style: solid;"><div dir=3D"ltr"><div>I want to change the name in the co=
ntext of my proposal of std::accumulate_first_if that there will be a commo=
n name for such types of algorithms.</div></div></blockquote><div><br>Actua=
lly I think it is better to change name of accumulate_first_if to accumulat=
e_while.<br> </div><blockquote class=3D"gmail_quote" style=3D"margin: =
0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204)=
; border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>=
By the way using std::find_if with a predicate resolves the two tasks: retu=
rning the count and the last iterator.</div></div></blockquote><div><br>I t=
hink terse notation does matter. <br></div></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_902_2570775.1381266530630--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Tue, 8 Oct 2013 16:09:54 -0500
Raw View
--047d7bdc979c12c22e04e84133fe
Content-Type: text/plain; charset=ISO-8859-1
On 8 October 2013 15:56, Evgeny Panasyuk <evgeny.panasyuk@gmail.com> wrote:
>
> But I don't really sure about ISO - there is long history of returning
> std::pair, like std::map::insert.
>
Well, I know how I'll vote... :-)
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7bdc979c12c22e04e84133fe
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 8 October 2013 15:56, Evgeny Panasyuk <span dir=3D"ltr"=
><<a href=3D"mailto:evgeny.panasyuk@gmail.com" target=3D"_blank">evgeny.=
panasyuk@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div=
class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>But I don't re=
ally sure about ISO - there is long history of returning std::pair, like st=
d::map::insert.<br>
</div></div></blockquote><div><br></div><div>Well, I know how I'll vote=
.... :-)<br></div></div></div><div class=3D"gmail_extra">-- <br>=A0Nevin &qu=
ot;:-)" Liber=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.com" =
target=3D"_blank">nevin@eviloverlord.com</a>>=A0 (847) 691-1404
</div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bdc979c12c22e04e84133fe--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 14:11:00 -0700 (PDT)
Raw View
------=_Part_544_25828889.1381266660714
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =D0=B3., 1:00:37 UTC+4 Daniel Kr=C3=BCgler:
>
> 2013/10/8 Evgeny Panasyuk <evgeny....@gmail.com <javascript:>>:=20
> > Alexander Stepanov used std::pair for that purpose at his "Efficient=20
> > Programming with Components" lectures=20
> Actually the Library does this already at several occasions:=20
>
Yes, that is why I inclined to std::pair, though personally I like=20
type-rich approach.
=20
> See also=20
> http://cplusplus.github.io/LWG/lwg-active.html#2242=20
> for another miss of useful information.=20
> Unfortunately,=20
> http://cplusplus.github.io/LWG/lwg-closed.html#1313=20
> was declared NAD. I think I will re-raise it soon.=20
>
That is unfortunate. But I am not sure how it can be fixed. New algorithm=
=20
or breaking change?
I remember that Alexander Stepanov mentioned that issue in "Efficient=20
Programming with Components".
He said something like: "First they throw away counted ranges for C++98. In=
=20
C++11 they tried to return something, but did it wrong." (maybe I will=20
find link a bit later).
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_544_25828889.1381266660714
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =D0=B3., 1:00:37 UTC+4 Daniel Kr=C3=BCgler=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;">2013/10/8 Evgeny Panasyuk <=
;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"1gIoTBn=
EL8oJ">evgeny....@gmail.com</a>>:
<br>> Alexander Stepanov used std::pair for that purpose at his "Efficie=
nt
<br>> Programming with Components" lectures
<br>Actually the Library does this already at several occasions:
<br></blockquote><div><br>Yes, that is why I inclined to std::pair, though =
personally I like type-rich approach.<br></div><div> <br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;">See also
<br><a href=3D"http://cplusplus.github.io/LWG/lwg-active.html#2242" target=
=3D"_blank">http://cplusplus.github.io/<wbr>LWG/lwg-active.html#2242</a>
<br>for another miss of useful information.
<br>Unfortunately,
<br><a href=3D"http://cplusplus.github.io/LWG/lwg-closed.html#1313" target=
=3D"_blank">http://cplusplus.github.io/<wbr>LWG/lwg-closed.html#1313</a>
<br>was declared NAD. I think I will re-raise it soon.
<br></blockquote><div><br>That is unfortunate. But I am not sure how it can=
be fixed. New algorithm or breaking change?<br><br>I remember that Alexand=
er Stepanov mentioned that issue in "Efficient Programming with Components"=
..<br>He said something like: "First they <span id=3D"result_box" class=3D"s=
hort_text" lang=3D"en"><span class=3D"hps alt-edited">throw away counted ra=
nges for</span></span> C++98. In C++11 they tried to <span id=3D"result_box=
" class=3D"short_text" lang=3D"en"><span class=3D"hps">return something, bu=
t did it wrong</span></span><span id=3D"result_box" class=3D"short_text" la=
ng=3D"en"><span class=3D"hps"></span></span>." (maybe I will find lin=
k a bit later).<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_544_25828889.1381266660714--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 14:13:28 -0700 (PDT)
Raw View
------=_Part_333_6847285.1381266808978
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
9 2013 =C7., 1:08:50 UTC+4 Vlad from Moscow :
>
> I would like to preserve the word "if" in such algorithms. We have for=20
> example copy_if, count_if and so on. So we could include copy_first_if,=
=20
> count_first_if and so on. It is a more consistent system of naming of=20
> algorithms.
>
Actually copy_if and count_if have different traversal semantic - they pass=
=20
thru whole input range.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_333_6847285.1381266808978
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 2013 =C7., 1:08:50 UTC+4 Vlad from Moscow :<blockqu=
ote 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>I would like to =
preserve the word "if" in such algorithms. We have for example copy_if, cou=
nt_if and so on. So we could include copy_first_if, count_first_if and so o=
n. It is a more consistent system of naming of algorithms.</div></div></blo=
ckquote><div><br>Actually copy_if and count_if have different traversal sem=
antic - they pass thru whole input range.<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_333_6847285.1381266808978--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 14:17:13 -0700 (PDT)
Raw View
------=_Part_548_20245446.1381267033384
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
Yes...and adding word first will point out that they traverse only first=20
elements that satisfy the condition.:)
=D3=D2=C5=C4=C1, 9 =CF=CB=D4=D1=C2=D2=D1 2013 =C7., 1:13:28 UTC+4 =D0=CF=CC=
=D8=DA=CF=D7=C1=D4=C5=CC=D8 Evgeny Panasyuk=20
=CE=C1=D0=C9=D3=C1=CC:
> 9 2013 =C7., 1:08:50 UTC+4 Vlad from Moscow :
>>
>> I would like to preserve the word "if" in such algorithms. We have for=
=20
>> example copy_if, count_if and so on. So we could include copy_first_if,=
=20
>> count_first_if and so on. It is a more consistent system of naming of=20
>> algorithms.
>>
>
> Actually copy_if and count_if have different traversal semantic - they=20
> pass thru whole input range.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_548_20245446.1381267033384
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Yes...and adding word first will point out that they =
traverse only first elements that satisfy the condition.:)</div><div><br>=
=D3=D2=C5=C4=C1, 9 =CF=CB=D4=D1=C2=D2=D1 2013 =C7., 1:13:28 UTC+4 =D0=
=CF=CC=D8=DA=CF=D7=C1=D4=C5=CC=D8 Evgeny Panasyuk =CE=C1=D0=C9=D3=C1=CC:</d=
iv><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; pa=
dding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: =
1px; border-left-style: solid;"><div dir=3D"ltr">9 2013 =C7., 1:08:50 =
UTC+4 Vlad from Moscow :<blockquote class=3D"gmail_quote" style=3D"margin: =
0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204)=
; border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>=
I would like to preserve the word "if" in such algorithms. We have for exam=
ple copy_if, count_if and so on. So we could include copy_first_if, count_f=
irst_if and so on. It is a more consistent system of naming of algorithms.<=
/div></div></blockquote><div><br>Actually copy_if and count_if have differe=
nt traversal semantic - they pass thru whole input range.<br></div></div></=
blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_548_20245446.1381267033384--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 8 Oct 2013 23:17:17 +0200
Raw View
2013/10/8 Evgeny Panasyuk <evgeny.panasyuk@gmail.com>:
> 9 oct 2013 =D0=B3., 1:00:37 UTC+4 Daniel Kr=C3=BCgler:
>> See also
>> http://cplusplus.github.io/LWG/lwg-active.html#2242
>> for another miss of useful information.
>> Unfortunately,
>> http://cplusplus.github.io/LWG/lwg-closed.html#1313
>> was declared NAD. I think I will re-raise it soon.
>
> That is unfortunate. But I am not sure how it can be fixed. New algorithm=
or
> breaking change?
I think the chances are good that the return type will be changed. We
did so in similar cases, such as in
http://cplusplus.github.io/LWG/lwg-defects.html#488
http://cplusplus.github.io/LWG/lwg-defects.html#865
> I remember that Alexander Stepanov mentioned that issue in "Efficient
> Programming with Components".
> He said something like: "First they throw away counted ranges for C++98. =
In
> C++11 they tried to return something, but did it wrong." (maybe I will f=
ind
> link a bit later).
;-)
- Daniel
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 14:29:39 -0700 (PDT)
Raw View
------=_Part_953_24400358.1381267779981
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =C7., 1:17:13 UTC+4 Vlad from Moscow:
>
> Yes...and adding word first will point out that they traverse only first=
=20
> elements that satisfy the condition.:)
>
I just think that count_first_if is not intuitive name. I think even=20
count_while_if would be better choice. (but I still prefer count_while)
Perhaps it is better to ask native English speakers.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_953_24400358.1381267779981
Content-Type: text/html; charset=KOI8-R
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =C7., 1:17:13 UTC+4 Vlad from Moscow:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Yes...and add=
ing word first will point out that they traverse only first elements that s=
atisfy the condition.:)</div></div></blockquote><div><br>I just think that =
count_first_if is not intuitive name. I think even count_while_if would be =
better choice. (but I still prefer count_while)<br>Perhaps it is better to =
ask native English speakers.<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_953_24400358.1381267779981--
.
Author: Magnus Fromreide <magfr@lysator.liu.se>
Date: Tue, 08 Oct 2013 23:34:54 +0200
Raw View
On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote:
> I want to change the name in the context of my proposal of
> std::accumulate_first_if that there will be a common name for such
> types of algorithms.
>
> By the way using std::find_if with a predicate resolves the two tasks:
> returning the count and the last iterator.
If we should change the names then I think the best name would be
distance_first_if
since it is about the distance from one point to another in a range, and
the end point is defined as the first entry matching a predicate.
(I also think the bikeshed should be pink)
/MF
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Tue, 8 Oct 2013 23:59:05 +0200
Raw View
--047d7b66f599f9b70904e841e23b
Content-Type: text/plain; charset=ISO-8859-1
I agree with Evgeny for the use of "while" and "until" instead of
"first_if". I think they are more intuitive and make more sense.
Concerning the return_type, it's true that std::pair is already used for
several component in the library and the algorithm shouldn't throw away a
useful information like the first not counted iterator.
2013/10/8 Magnus Fromreide <magfr@lysator.liu.se>
> On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote:
> > I want to change the name in the context of my proposal of
> > std::accumulate_first_if that there will be a common name for such
> > types of algorithms.
> >
> > By the way using std::find_if with a predicate resolves the two tasks:
> > returning the count and the last iterator.
>
> If we should change the names then I think the best name would be
>
> distance_first_if
>
> since it is about the distance from one point to another in a range, and
> the end point is defined as the first entry matching a predicate.
>
> (I also think the bikeshed should be pink)
>
> /MF
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--047d7b66f599f9b70904e841e23b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>I agree with Evgeny for the use of "while&q=
uot; and "until" instead of "first_if". I think they ar=
e more intuitive and make more sense.<br><br></div>Concerning the return_ty=
pe, it's true that std::pair is already used for several component in t=
he library and the algorithm shouldn't throw away a useful information =
like the first not counted iterator.<br>
</div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2=
013/10/8 Magnus Fromreide <span dir=3D"ltr"><<a href=3D"mailto:magfr@lys=
ator.liu.se" target=3D"_blank">magfr@lysator.liu.se</a>></span><br><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex">
<div class=3D"im">On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote=
:<br>
> I want to change the name in the context of my proposal of<br>
> std::accumulate_first_if that there will be a common name for such<br>
> types of algorithms.<br>
><br>
> By the way using std::find_if with a predicate resolves the two tasks:=
<br>
> returning the count and the last iterator.<br>
<br>
</div>If we should change the names then I think the best name would be<br>
<br>
distance_first_if<br>
<br>
since it is about the distance from one point to another in a range, and<br=
>
the end point is defined as the first entry matching a predicate.<br>
<br>
(I also think the bikeshed should be pink)<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
/MF<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-proposals+unsubscrib=
e@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7b66f599f9b70904e841e23b--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 8 Oct 2013 15:09:18 -0700 (PDT)
Raw View
------=_Part_1065_5911945.1381270159049
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
As I pointed already I think that it would be enough to have only one=20
algorithm because you always can get the negation of a predicate at least=
=20
using lambda expressions.
=20
As for the name then it should be consistent with names of similar by logic=
=20
algorithms.
=20
"if" in the name points out that a predicate is used. At present it is a=20
general approach of naming algorithms with a predicate in the C++ Standard.
=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 1:59:05 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
> I agree with Evgeny for the use of "while" and "until" instead of=20
> "first_if". I think they are more intuitive and make more sense.
>
> Concerning the return_type, it's true that std::pair is already used for=
=20
> several component in the library and the algorithm shouldn't throw away a=
=20
> useful information like the first not counted iterator.
>
>
> 2013/10/8 Magnus Fromreide <ma...@lysator.liu.se <javascript:>>
>
>> On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote:
>> > I want to change the name in the context of my proposal of
>> > std::accumulate_first_if that there will be a common name for such
>> > types of algorithms.
>> >
>> > By the way using std::find_if with a predicate resolves the two tasks:
>> > returning the count and the last iterator.
>>
>> If we should change the names then I think the best name would be
>>
>> distance_first_if
>>
>> since it is about the distance from one point to another in a range, and
>> the end point is defined as the first entry matching a predicate.
>>
>> (I also think the bikeshed should be pink)
>>
>> /MF
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to a topic in the=
=20
>> Google Groups "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this topic, visit=20
>> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to=20
>> std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1065_5911945.1381270159049
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>As I pointed already I think that it would be&nb=
sp;enough to have only one algorithm because you always can get the ne=
gation of a predicate at least using lambda expressions.</div><div> </=
div><div>As for the name then it should be consistent with names of si=
milar by logic algorithms.</div><div> </div><div>"if" in the name poin=
ts out that a predicate is used. At present it is a general approach o=
f naming algorithms with a predicate in the C++ Standard.</div><div><br>=D1=
=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2=
013 =D0=B3., 1:59:05 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:</div><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204=
); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div=
><div>I agree with Evgeny for the use of "while" and "until" instead of "fi=
rst_if". I think they are more intuitive and make more sense.<br><br></div>=
Concerning the return_type, it's true that std::pair is already used for se=
veral component in the library and the algorithm shouldn't throw away a use=
ful information like the first not counted iterator.<br>
</div></div><div><br><br><div class=3D"gmail_quote">2013/10/8 Magnus Fromre=
ide <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-obf=
uscated-mailto=3D"rb3tv2luN-sJ">ma...@lysator.liu.se</a>></span><br><blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-l=
eft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bo=
rder-left-style: solid;">
<div>On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote:<br>
> I want to change the name in the context of my proposal of<br>
> std::accumulate_first_if that there will be a common name for such<br>
> types of algorithms.<br>
><br>
> By the way using std::find_if with a predicate resolves the two tasks:=
<br>
> returning the count and the last iterator.<br>
<br>
</div>If we should change the names then I think the best name would be<br>
<br>
distance_first_if<br>
<br>
since it is about the distance from one point to another in a range, and<br=
>
the end point is defined as the first entry matching a predicate.<br>
<br>
(I also think the bikeshed should be pink)<br>
<span><font color=3D"#888888"><br>
/MF<br>
</font></span><div><div><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/<wbr>isocpp.org/d/topic/std-<wbr>proposals/b=
XrQrkBw59c/<wbr>unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"rb3tv2luN-sJ">s=
td-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"rb3tv2luN-sJ">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/<wbr>isocpp.or=
g/group/std-<wbr>proposals/</a>.<br>
</div></div></blockquote></div><br></div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1065_5911945.1381270159049--
.
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Wed, 9 Oct 2013 00:35:47 +0200
Raw View
--089e011779b541f3d504e8426606
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I agree one algorithm could be enough. But it should be more convenient to
have both of them. C++11 added for example find_if_not that is exactly
find_if + not1.
For the name, as pointed out by Evgeny, "_if" has another semantic, that is
to pass through the entire range and perform action only when a predicate
is true (except for find_if). Instead, "_while" and "_until" should perform
a action while and until a predicate is true, respectively. There is
already is_heap_until using this kind of suffix.
2013/10/9 Vlad from Moscow <vlad.moscow@mail.ru>
> As I pointed already I think that it would be enough to have only one
> algorithm because you always can get the negation of a predicate at least
> using lambda expressions.
>
> As for the name then it should be consistent with names of similar by
> logic algorithms.
>
> "if" in the name points out that a predicate is used. At present it is a
> general approach of naming algorithms with a predicate in the C++ Standar=
d.
>
> =D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 1:59:05 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>
>> I agree with Evgeny for the use of "while" and "until" instead of
>> "first_if". I think they are more intuitive and make more sense.
>>
>> Concerning the return_type, it's true that std::pair is already used for
>> several component in the library and the algorithm shouldn't throw away =
a
>> useful information like the first not counted iterator.
>>
>>
>> 2013/10/8 Magnus Fromreide <ma...@lysator.liu.se>
>>
>>> On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote:
>>> > I want to change the name in the context of my proposal of
>>> > std::accumulate_first_if that there will be a common name for such
>>> > types of algorithms.
>>> >
>>> > By the way using std::find_if with a predicate resolves the two tasks=
:
>>> > returning the count and the last iterator.
>>>
>>> If we should change the names then I think the best name would be
>>>
>>> distance_first_if
>>>
>>> since it is about the distance from one point to another in a range, an=
d
>>> the end point is defined as the first entry matching a predicate.
>>>
>>> (I also think the bikeshed should be pink)
>>>
>>> /MF
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/a/**
>>> isocpp.org/d/topic/std-**proposals/bXrQrkBw59c/**unsubscribe<https://gr=
oups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe>
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> std-proposal...@**isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>>
>>> Visit this group at http://groups.google.com/a/**isocpp.org/group/std-*=
*
>>> proposals/ <http://groups.google.com/a/isocpp.org/group/std-proposals/>=
..
>>>
>>
>> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--089e011779b541f3d504e8426606
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I agree one algorithm could be enough. But it should be mo=
re convenient to have both of them. C++11 added for example find_if_not tha=
t is exactly find_if + not1.<br><div><br>For the name, as pointed out by Ev=
geny, "_if" has another semantic, that is to pass through the ent=
ire range and perform action only when a predicate is true (except for find=
_if). Instead, "_while" and "_until" should perform a a=
ction while and until a predicate is true, respectively. There is already i=
s_heap_until using this kind of suffix. <br>
</div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2=
013/10/9 Vlad from Moscow <span dir=3D"ltr"><<a href=3D"mailto:vlad.mosc=
ow@mail.ru" target=3D"_blank">vlad.moscow@mail.ru</a>></span><br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex">
<div dir=3D"ltr"><div>As I pointed already I think that it=C2=A0would be=C2=
=A0enough to have only one algorithm because you always can get=C2=A0the ne=
gation of a predicate at least using lambda expressions.</div><div>=C2=A0</=
div><div>As for the name then it should be consistent=C2=A0with names of si=
milar by logic algorithms.</div>
<div>=C2=A0</div><div>"if" in the name points out=C2=A0that a pre=
dicate is used. At present it is a general approach of naming algorithms wi=
th a predicate in the C++ Standard.</div><div><br>=D1=81=D1=80=D0=B5=D0=B4=
=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013=C2=A0=D0=B3., 1:5=
9:05 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=
=BB=D1=8C R=C3=A9my Lefevre =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</di=
v>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid"><div class=3D"im"><div dir=3D"ltr"><div><div>I agree with =
Evgeny for the use of "while" and "until" instead of &q=
uot;first_if". I think they are more intuitive and make more sense.<br=
>
<br></div>Concerning the return_type, it's true that std::pair is alrea=
dy used for several component in the library and the algorithm shouldn'=
t throw away a useful information like the first not counted iterator.<br>
</div></div></div><div><br><br><div class=3D"gmail_quote">2013/10/8 Magnus =
Fromreide <span dir=3D"ltr"><<a>ma...@lysator.liu.se</a>></span><br><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-=
left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-le=
ft-style:solid">
<div class=3D"im">
<div>On Tue, 2013-10-08 at 13:56 -0700, Vlad from Moscow wrote:<br>
> I want to change the name in the context of my proposal of<br>
> std::accumulate_first_if that there will be a common name for such<br>
> types of algorithms.<br>
><br>
> By the way using std::find_if with a predicate resolves the two tasks:=
<br>
> returning the count and the last iterator.<br>
<br>
</div>If we should change the names then I think the best name would be<br>
<br>
distance_first_if<br>
<br>
since it is about the distance from one point to another in a range, and<br=
>
the end point is defined as the first entry matching a predicate.<br>
<br>
(I also think the bikeshed should be pink)<br>
<span><font color=3D"#888888"><br>
/MF<br>
</font></span></div><div><div><div class=3D"im"><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/<u></u>isocpp.org/d/topic/std-<u></u>proposa=
ls/bXrQrkBw59c/<u></u>unsubscribe</a>.<br>
</div>
To unsubscribe from this group and all its topics, send an email to <a>std-=
proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<div class=
=3D"im"><br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</div></div></div></blockquote></div><br></div>
</blockquote></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--089e011779b541f3d504e8426606--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 15:38:49 -0700 (PDT)
Raw View
------=_Part_614_4583462.1381271929677
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =D0=B3., 2:35:47 UTC+4 R=C3=A9my Lefevre :
>
> I agree one algorithm could be enough. But it should be more convenient t=
o=20
> have both of them. C++11 added for example find_if_not that is exactly=20
> find_if + not1.
>
Alexander Stepanov talks about that specific issue ( std::find_if_not ):=20
http://www.youtube.com/watch?v=3DdUEA8fHx0r0&t=3D26m45s
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_614_4583462.1381271929677
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">9 oct 2013 =D0=B3., 2:35:47 UTC+4 R=C3=A9my Lefevre :=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">I agree one a=
lgorithm could be enough. But it should be more convenient to have both of =
them. C++11 added for example find_if_not that is exactly find_if + not1.<b=
r><div></div></div></blockquote><div><br>Alexander Stepanov talks about tha=
t specific issue ( std::find_if_not ): http://www.youtube.com/watch?v=3DdUE=
A8fHx0r0&t=3D26m45s<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_614_4583462.1381271929677--
.
Author: Evgeny Panasyuk <evgeny.panasyuk@gmail.com>
Date: Tue, 8 Oct 2013 15:59:48 -0700 (PDT)
Raw View
------=_Part_993_6675106.1381273188716
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
9 oct 2013 =D0=B3., 1:17:17 UTC+4 Daniel Kr=C3=BCgler :
>
> 2013/10/8 Evgeny Panasyuk <evgeny....@gmail.com <javascript:>>:=20
> > 9 oct 2013 =D0=B3., 1:00:37 UTC+4 Daniel Kr=C3=BCgler:=20
> >> See also=20
> >> http://cplusplus.github.io/LWG/lwg-active.html#2242=20
> >> for another miss of useful information.=20
> >> Unfortunately,=20
> >> http://cplusplus.github.io/LWG/lwg-closed.html#1313=20
> >> was declared NAD. I think I will re-raise it soon.=20
> >=20
> > That is unfortunate. But I am not sure how it can be fixed. New=20
> algorithm or=20
> > breaking change?=20
>
> I think the chances are good that the return type will be changed. We=20
> did so in similar cases, such as in=20
>
> http://cplusplus.github.io/LWG/lwg-defects.html#488=20
> http://cplusplus.github.io/LWG/lwg-defects.html#865=20
>
These are a bit different case - originally they had void return type, and=
=20
it is easy to change void to something.
But in case of std::copy_n - it already has some return type, and change of=
=20
that type would be breaking change.
=20
>
> > I remember that Alexander Stepanov mentioned that issue in "Efficient=
=20
> > Programming with Components".=20
> > He said something like: "First they throw away counted ranges for C++98=
..=20
> In=20
> > C++11 they tried to return something, but did it wrong." (maybe I will=
=20
> find=20
> > link a bit later).=20
>
> ;-)=20
>
Ok, I have found that moment regarding copy_n:=20
http://www.youtube.com/watch?v=3DdUEA8fHx0r0&t=3D35m14s
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_993_6675106.1381273188716
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"> 9 oct 2013 =D0=B3., 1:17:17 UTC+4 Daniel Kr=C3=
=BCgler :<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">2013/10/8 Evgeny Pana=
syuk <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D=
"9tvIHUiEc0IJ">evgeny....@gmail.com</a>>:
<br>> 9 oct 2013 =D0=B3., 1:00:37 UTC+4 Daniel Kr=C3=BCgler:
<br>>> See also
<br>>> <a href=3D"http://cplusplus.github.io/LWG/lwg-active.html#2242=
" target=3D"_blank">http://cplusplus.github.io/<wbr>LWG/lwg-active.html#224=
2</a>
<br>>> for another miss of useful information.
<br>>> Unfortunately,
<br>>> <a href=3D"http://cplusplus.github.io/LWG/lwg-closed.html#1313=
" target=3D"_blank">http://cplusplus.github.io/<wbr>LWG/lwg-closed.html#131=
3</a>
<br>>> was declared NAD. I think I will re-raise it soon.
<br>>
<br>> That is unfortunate. But I am not sure how it can be fixed. New al=
gorithm or
<br>> breaking change?
<br>
<br>I think the chances are good that the return type will be changed. We
<br>did so in similar cases, such as in
<br>
<br><a href=3D"http://cplusplus.github.io/LWG/lwg-defects.html#488" target=
=3D"_blank">http://cplusplus.github.io/<wbr>LWG/lwg-defects.html#488</a>
<br><a href=3D"http://cplusplus.github.io/LWG/lwg-defects.html#865" target=
=3D"_blank">http://cplusplus.github.io/<wbr>LWG/lwg-defects.html#865</a>
<br></blockquote><div><br>These are a bit different case - originally they =
had void return type, and it is easy to change void to something.<br>But in=
case of std::copy_n - it already has some return type, and change of that =
type would be breaking change.<br> </div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;">
<br>> I remember that Alexander Stepanov mentioned that issue in "Effici=
ent
<br>> Programming with Components".
<br>> He said something like: "First they throw away counted ranges for =
C++98. In
<br>> C++11 they tried to return something, but did it wrong." (ma=
ybe I will find
<br>> link a bit later).
<br>
<br>;-)
<br></blockquote><div><br>Ok, I have found that moment regarding copy_n: ht=
tp://www.youtube.com/watch?v=3DdUEA8fHx0r0&t=3D35m14s<br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_993_6675106.1381273188716--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Wed, 9 Oct 2013 01:02:46 +0200
Raw View
2013/10/9 Evgeny Panasyuk <evgeny.panasyuk@gmail.com>:
> 9 oct 2013 =D0=B3., 1:17:17 UTC+4 Daniel Kr=C3=BCgler :
>>
>> 2013/10/8 Evgeny Panasyuk <evgeny....@gmail.com>:
>> > 9 oct 2013 =D0=B3., 1:00:37 UTC+4 Daniel Kr=C3=BCgler:
>> >> See also
>> >> http://cplusplus.github.io/LWG/lwg-active.html#2242
>> >> for another miss of useful information.
>> >> Unfortunately,
>> >> http://cplusplus.github.io/LWG/lwg-closed.html#1313
>> >> was declared NAD. I think I will re-raise it soon.
>> >
>> > That is unfortunate. But I am not sure how it can be fixed. New
>> > algorithm or
>> > breaking change?
>>
>> I think the chances are good that the return type will be changed. We
>> did so in similar cases, such as in
>>
>> http://cplusplus.github.io/LWG/lwg-defects.html#488
>> http://cplusplus.github.io/LWG/lwg-defects.html#865
>
> These are a bit different case - originally they had void return type, an=
d
> it is easy to change void to something.
> But in case of std::copy_n - it already has some return type, and change =
of
> that type would be breaking change.
Nonetheless it was a breaking change, because you can take pointers to
instantiations of free library function templates. I agree that the
chances are smaller that this was a problem for someone.
- Daniel
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Benjamin Lindley <benjameslindley@gmail.com>
Date: Tue, 8 Oct 2013 22:13:02 -0700 (PDT)
Raw View
------=_Part_1690_26279800.1381295582429
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
What about creating an iterator adapter instead? One which keeps track of=
=20
how many times it has been incremented?
typedef std::istream_iterator<int> base_t;
base_t ib(std::cin), ie;
std::counting_iterator<base_t> b(ib), e(ie);
auto p =3D std::find_if(b, e, pred);
std::cout << p.count();
Then you could apply it to other algorithms besides find/find_if.
On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre wrote:
>
> Hi,
>
> I thought about two new algorithms, that could be named "count_while" and=
=20
> "count_until". Here are their behavior:
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_while (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
> }
>
>
> template <class InputIterator, class UnaryPredicate>
>
>
> typename iterator_traits<InputIterator>::difference_type
>
>
> count_until (InputIterator first, InputIterator last, UnaryPredicate =
pred)
>
> {
>
> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>
>
> while (first!=3Dlast && !pred(*first)) {
>
>
> ++ret;
> ++first;
>
>
> }
> return ret;
>
>
> }
>
>
> What do you think about adding these two components to the algorithms=20
> library ?
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1690_26279800.1381295582429
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">What about creating an iterator adapter instead? One=
which keeps track of how many times it has been incremented?<br><br><div c=
lass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-=
color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wra=
p: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><=
span style=3D"color: #008;" class=3D"styled-by-prettify">typedef</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">istream_iterator</span><span style=
=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> base_t</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>base_t ib</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">cin</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> ie</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">counting_iterator</span><=
span style=3D"color: #080;" class=3D"styled-by-prettify"><base_t></sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">ib</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> e</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">ie</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> p </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=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_if</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> pred</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> p</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">count</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span></div></code></div><br>Then you could apply it to other algorith=
ms besides find/find_if.<br><br>On Tuesday, October 8, 2013 3:04:23 PM UTC-=
5, R=E9my Lefevre wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div d=
ir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could be nam=
ed "count_while" and "count_until". Here are their behavior:<br><br><div st=
yle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bord=
er-style:solid;border-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
02,102,0)"><</span><var><span style=3D"color:rgb(0,0,136)">class</span><=
/var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,=
0,102)">InputIterator</span><span style=3D"color:rgb(102,102,0)">,</span><s=
pan style=3D"color:rgb(0,0,0)"> </span><var><span style=3D"color:rgb(0,0,13=
6)">class</span></var><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102=
,102,0)">></span><span style=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">typename</span></var>=
<span style=3D"color:rgb(0,0,0)"> iterator_traits</span><span style=3D"colo=
r:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIter=
ator</span><span style=3D"color:rgb(102,102,0)">><wbr>::</span><span sty=
le=3D"color:rgb(0,0,0)">difference_type<br>
count_while </span><span style=3D"color:rgb(102,102,0)">(</sp=
an><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"=
color:rgb(0,0,0)"> first</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,10=
2)">InputIterator</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,0,102)">UnaryPredicate</span><span style=3D"color:rgb(0,0,0)"> pred</span>=
<span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0=
)"><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rg=
b(0,0,0)"><br> </span><var><span style=3D"color:rgb(0,0,136)">typenam=
e</span></var><span style=3D"color:rgb(0,0,0)"> iterator_traits</span><span=
style=3D"color:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,1=
02)">InputIterator</span><span style=3D"color:rgb(102,102,0)">><wbr>::</=
span><span style=3D"color:rgb(0,0,0)">difference_type ret </span><span styl=
e=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(10=
2,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">while</span></var><sp=
an style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">=
(</span><span style=3D"color:rgb(0,0,0)">first</span><span style=3D"color:r=
gb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,136)">last</span><va=
r><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">&&</span><span style=3D"color:rgb(0,0,0)"> </span></var><var><=
/var><span style=3D"color:rgb(0,0,0)">pred</span><span style=3D"color:rgb(1=
02,102,0)">(*</span><span style=3D"color:rgb(0,0,0)">first</span><span styl=
e=3D"color:rgb(102,102,0)">))</span><span style=3D"color:rgb(0,0,0)"> </spa=
n><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0=
,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle=3D"color:rgb(0,0,0)">ret</span><span style=3D"color:rgb(102,102,0)">;</=
span><span style=3D"color:rgb(0,0,0)"><br> </span><span style=
=3D"color:rgb(102,102,0)">++</span><span style=3D"color:rgb(0,0,0)">first</=
span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(=
0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br> </span><var><span style=3D"color:rgb(0,0,136)">=
return</span></var><span style=3D"color:rgb(0,0,0)"> ret</span><span style=
=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
02,102,0)"><</span><var><span style=3D"color:rgb(0,0,136)">class</span><=
/var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,=
0,102)">InputIterator</span><span style=3D"color:rgb(102,102,0)">,</span><s=
pan style=3D"color:rgb(0,0,0)"> </span><var><span style=3D"color:rgb(0,0,13=
6)">class</span></var><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102=
,102,0)">></span><span style=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">typename</span></var>=
<span style=3D"color:rgb(0,0,0)"> iterator_traits</span><span style=3D"colo=
r:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIter=
ator</span><span style=3D"color:rgb(102,102,0)">><wbr>::</span><span sty=
le=3D"color:rgb(0,0,0)">difference_type<br>
count_until </span><span style=3D"color:rgb(102,102,0)">(</sp=
an><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"=
color:rgb(0,0,0)"> first</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,10=
2)">InputIterator</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,0,102)">UnaryPredicate</span><span style=3D"color:rgb(0,0,0)"> pred</span>=
<span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0=
)"><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rg=
b(0,0,0)"><br><code><pre><code><span style=3D"color:rgb(0,0,0)"> </sp=
an><var><span style=3D"color:rgb(0,0,136)">typename</span></var><span style=
=3D"color:rgb(0,0,0)"> iterator_traits</span><span style=3D"color:rgb(102,1=
02,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIterator</span>=
<span style=3D"color:rgb(102,102,0)">><wbr>::</span><span style=3D"color=
:rgb(0,0,0)">difference_type ret </span><span style=3D"color:rgb(102,102,0)=
">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">;</span><span s=
tyle=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">while</span></var><sp=
an style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">=
(</span><span style=3D"color:rgb(0,0,0)">first</span><span style=3D"color:r=
gb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,136)">last</span><va=
r><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">&&</span><span style=3D"color:rgb(0,0,0)"> </span></var><var><=
/var><span style=3D"color:rgb(0,0,0)">!pred</span><span style=3D"color:rgb(=
102,102,0)">(*</span><span style=3D"color:rgb(0,0,0)">first</span><span sty=
le=3D"color:rgb(102,102,0)">))</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,=
0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle=3D"color:rgb(0,0,0)">ret</span><span style=3D"color:rgb(102,102,0)">;</=
span><span style=3D"color:rgb(0,0,0)"><br> </span><span style=
=3D"color:rgb(102,102,0)">++</span><span style=3D"color:rgb(0,0,0)">first</=
span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(=
0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br> </span><var><span style=3D"color:rgb(0,0,136)">=
return</span></var><span style=3D"color:rgb(0,0,0)"> ret;<br>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span style=3D"color:rgb(0,0,0)"></span><span style=3D"col=
or:rgb(102,102,0)"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1690_26279800.1381295582429--
.
Author: Peter Sommerlad <Peter.Sommerlad@hsr.ch>
Date: Wed, 9 Oct 2013 07:58:28 +0200
Raw View
--Apple-Mail-B36A059F-E1FB-4422-B3F9-1AC3C3F9687A
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
+1 for composability instead of proliferation...
Do we have boost's counting iterator adapter in c++14 or library TS?
Sent from Peter Sommerlad's iPad
On 09.10.2013, at 07:13, "Benjamin Lindley" <benjameslindley@gmail.com> wro=
te:
> What about creating an iterator adapter instead? One which keeps track o=
f how many times it has been incremented?
>=20
> typedef std::istream_iterator<int> base_t;
> base_t ib(std::cin), ie;
> std::counting_iterator<base_t> b(ib), e(ie);
> auto p =3D std::find_if(b, e, pred);
> std::cout << p.count();
>=20
> Then you could apply it to other algorithms besides find/find_if.
>=20
> On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre wrote:
>>=20
>> Hi,
>>=20
>> I thought about two new algorithms, that could be named "count_while" an=
d "count_until". Here are their behavior:
>>=20
>> template <class InputIterator, class UnaryPredicate>
>>=20
>>=20
>> typename iterator_traits<InputIterator>::difference_type
>>=20
>>=20
>> count_while (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>=20
>>=20
>> {
>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>=20
>>=20
>> while (first!=3Dlast && pred(*first)) {
>>=20
>>=20
>> ++ret;
>> ++first;
>>=20
>>=20
>> }
>> return ret;
>>=20
>>=20
>> }
>>=20
>> template <class InputIterator, class UnaryPredicate>
>>=20
>>=20
>> typename iterator_traits<InputIterator>::difference_type
>>=20
>>=20
>> count_until (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>=20
>>=20
>> {
>> typename iterator_traits<InputIterator>::difference_type ret =3D 0;
>>=20
>>=20
>> while (first!=3Dlast && !pred(*first)) {
>>=20
>>=20
>> ++ret;
>> ++first;
>>=20
>>=20
>> }
>> return ret;
>>=20
>>=20
>> }
>>=20
>> What do you think about adding these two components to the algorithms li=
brary ?
>=20
> --=20
> =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.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-propo=
sals/.
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail-B36A059F-E1FB-4422-B3F9-1AC3C3F9687A
Content-Type: text/html; charset=ISO-8859-1
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>+1 for composability instead of pr=
oliferation...</div><div><br></div><div>Do we have boost's counting iterato=
r adapter in c++14 or library TS?<br><br>Sent from Peter Sommerlad's<span c=
lass=3D"Apple-style-span" style=3D"-webkit-tap-highlight-color: rgba(26, 26=
, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.2304=
69); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); "> =
;iPad</span></div><div><br>On 09.10.2013, at 07:13, "Benjamin Lindley" <=
<a href=3D"mailto:benjameslindley@gmail.com">benjameslindley@gmail.com</a>&=
gt; wrote:<br><br></div><blockquote type=3D"cite"><div><meta http-equiv=3D"=
Content-Type" content=3D"text/html; charset=3Diso-8859-1"><div dir=3D"ltr">=
What about creating an iterator adapter instead? One which keeps trac=
k of how many times it has been incremented?<br><br><div class=3D"prettypri=
nt" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 1=
87, 187); border-style: solid; border-width: 1px; word-wrap: break-word;"><=
code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">typedef</span><span style=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">istream_iterator</span><span style=3D"color: #080;"=
class=3D"styled-by-prettify"><int></span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> base_t</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>base_t ib</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
cin</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> ie</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">counting_iterator</span><span style=3D"col=
or: #080;" class=3D"styled-by-prettify"><base_t></span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">ib</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">),</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> e</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ie</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> p </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=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_if</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> e</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> pred</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br>std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">cout </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> p</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">count</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></=
code></div><br>Then you could apply it to other algorithms besides find/fin=
d_if.<br><br>On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre w=
rote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Hi,<br><=
br>I thought about two new algorithms, that could be named "count_while" an=
d "count_until". Here are their behavior:<br><br><div style=3D"background-c=
olor:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bord=
er-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
02,102,0)"><</span><var><span style=3D"color:rgb(0,0,136)">class</span><=
/var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,=
0,102)">InputIterator</span><span style=3D"color:rgb(102,102,0)">,</span><s=
pan style=3D"color:rgb(0,0,0)"> </span><var><span style=3D"color:rgb(0,0,13=
6)">class</span></var><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102=
,102,0)">></span><span style=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">typename</span></var>=
<span style=3D"color:rgb(0,0,0)"> iterator_traits</span><span style=3D"colo=
r:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIter=
ator</span><span style=3D"color:rgb(102,102,0)">><wbr>::</span><span sty=
le=3D"color:rgb(0,0,0)">difference_type<br>
count_while </span><span style=3D"color:rgb(102,102,0)">(</sp=
an><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"=
color:rgb(0,0,0)"> first</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,10=
2)">InputIterator</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,0,102)">UnaryPredicate</span><span style=3D"color:rgb(0,0,0)"> pred</span>=
<span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0=
)"><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rg=
b(0,0,0)"><br> </span><var><span style=3D"color:rgb(0,0,136)">typenam=
e</span></var><span style=3D"color:rgb(0,0,0)"> iterator_traits</span><span=
style=3D"color:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,1=
02)">InputIterator</span><span style=3D"color:rgb(102,102,0)">><wbr>::</=
span><span style=3D"color:rgb(0,0,0)">difference_type ret </span><span styl=
e=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(10=
2,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">while</span></var><sp=
an style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">=
(</span><span style=3D"color:rgb(0,0,0)">first</span><span style=3D"color:r=
gb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,136)">last</span><va=
r><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">&&</span><span style=3D"color:rgb(0,0,0)"> </span></var><var><=
/var><span style=3D"color:rgb(0,0,0)">pred</span><span style=3D"color:rgb(1=
02,102,0)">(*</span><span style=3D"color:rgb(0,0,0)">first</span><span styl=
e=3D"color:rgb(102,102,0)">))</span><span style=3D"color:rgb(0,0,0)"> </spa=
n><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0=
,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle=3D"color:rgb(0,0,0)">ret</span><span style=3D"color:rgb(102,102,0)">;</=
span><span style=3D"color:rgb(0,0,0)"><br> </span><span style=
=3D"color:rgb(102,102,0)">++</span><span style=3D"color:rgb(0,0,0)">first</=
span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(=
0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br> </span><var><span style=3D"color:rgb(0,0,136)">=
return</span></var><span style=3D"color:rgb(0,0,0)"> ret</span><span style=
=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
02,102,0)"><</span><var><span style=3D"color:rgb(0,0,136)">class</span><=
/var><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,=
0,102)">InputIterator</span><span style=3D"color:rgb(102,102,0)">,</span><s=
pan style=3D"color:rgb(0,0,0)"> </span><var><span style=3D"color:rgb(0,0,13=
6)">class</span></var><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102=
,102,0)">></span><span style=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">typename</span></var>=
<span style=3D"color:rgb(0,0,0)"> iterator_traits</span><span style=3D"colo=
r:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIter=
ator</span><span style=3D"color:rgb(102,102,0)">><wbr>::</span><span sty=
le=3D"color:rgb(0,0,0)">difference_type<br>
count_until </span><span style=3D"color:rgb(102,102,0)">(</sp=
an><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"=
color:rgb(0,0,0)"> first</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,10=
2)">InputIterator</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,0,102)">UnaryPredicate</span><span style=3D"color:rgb(0,0,0)"> pred</span>=
<span style=3D"color:rgb(102,102,0)">)</span><span style=3D"color:rgb(0,0,0=
)"><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rg=
b(0,0,0)"><br><code><pre><code><span style=3D"color:rgb(0,0,0)"> </sp=
an><var><span style=3D"color:rgb(0,0,136)">typename</span></var><span style=
=3D"color:rgb(0,0,0)"> iterator_traits</span><span style=3D"color:rgb(102,1=
02,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIterator</span>=
<span style=3D"color:rgb(102,102,0)">><wbr>::</span><span style=3D"color=
:rgb(0,0,0)">difference_type ret </span><span style=3D"color:rgb(102,102,0)=
">=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">;</span><span s=
tyle=3D"color:rgb(0,0,0)"><br>
</span><var><span style=3D"color:rgb(0,0,136)">while</span></var><sp=
an style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">=
(</span><span style=3D"color:rgb(0,0,0)">first</span><span style=3D"color:r=
gb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,136)">last</span><va=
r><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">&&</span><span style=3D"color:rgb(0,0,0)"> </span></var><var><=
/var><span style=3D"color:rgb(0,0,0)">!pred</span><span style=3D"color:rgb(=
102,102,0)">(*</span><span style=3D"color:rgb(0,0,0)">first</span><span sty=
le=3D"color:rgb(102,102,0)">))</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,=
0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">++</span><span st=
yle=3D"color:rgb(0,0,0)">ret</span><span style=3D"color:rgb(102,102,0)">;</=
span><span style=3D"color:rgb(0,0,0)"><br> </span><span style=
=3D"color:rgb(102,102,0)">++</span><span style=3D"color:rgb(0,0,0)">first</=
span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(=
0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span><span style=3D"c=
olor:rgb(0,0,0)"><br> </span><var><span style=3D"color:rgb(0,0,136)">=
return</span></var><span style=3D"color:rgb(0,0,0)"> ret;<br>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span style=3D"color:rgb(0,0,0)"></span><span style=3D"col=
or:rgb(102,102,0)"></span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br>
<br>
--- <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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br>
</div></blockquote></body></html>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail-B36A059F-E1FB-4422-B3F9-1AC3C3F9687A--
.
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Wed, 9 Oct 2013 10:58:36 +0200
Raw View
--bcaec53f346f9aff1804e84b19da
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Good point for a counting iterator ! Unfortunately, the one in boost
library doesn't fit our need here and I am not aware of any counting
iterator in C++14.
2013/10/9 Peter Sommerlad <Peter.Sommerlad@hsr.ch>
> +1 for composability instead of proliferation...
>
> Do we have boost's counting iterator adapter in c++14 or library TS?
>
> Sent from Peter Sommerlad's iPad
>
> On 09.10.2013, at 07:13, "Benjamin Lindley" <benjameslindley@gmail.com>
> wrote:
>
> What about creating an iterator adapter instead? One which keeps track o=
f
> how many times it has been incremented?
>
> typedef std::istream_iterator<int> base_t;
> base_t ib(std::cin), ie;
> std::counting_iterator<base_t> b(ib), e(ie);
> auto p =3D std::find_if(b, e, pred);
> std::cout << p.count();
>
> Then you could apply it to other algorithms besides find/find_if.
>
> On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre wrote:
>>
>> Hi,
>>
>> I thought about two new algorithms, that could be named "count_while" an=
d
>> "count_until". Here are their behavior:
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>>
>> typename iterator_traits<InputIterator>**::difference_type
>>
>>
>>
>> count_while (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>>
>> {
>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0;
>>
>>
>>
>> while (first!=3Dlast && pred(*first)) {
>>
>>
>>
>> ++ret;
>> ++first;
>>
>>
>>
>> }
>> return ret;
>>
>> }
>>
>>
>> template <class InputIterator, class UnaryPredicate>
>>
>>
>>
>> typename iterator_traits<InputIterator>**::difference_type
>>
>>
>>
>> count_until (InputIterator first, InputIterator last, UnaryPredicate=
pred)
>>
>>
>> {
>>
>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0;
>>
>>
>>
>> while (first!=3Dlast && !pred(*first)) {
>>
>>
>>
>> ++ret;
>> ++first;
>>
>>
>>
>> }
>> return ret;
>>
>>
>> }
>>
>>
>> What do you think about adding these two components to the algorithms
>> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--bcaec53f346f9aff1804e84b19da
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Good point for a counting iterator ! Unfortunately, the on=
e in boost library doesn't fit our need here and I am not aware of any =
counting iterator in C++14.<br></div><div class=3D"gmail_extra"><br><br><di=
v class=3D"gmail_quote">
2013/10/9 Peter Sommerlad <span dir=3D"ltr"><<a href=3D"mailto:Peter.Som=
merlad@hsr.ch" target=3D"_blank">Peter.Sommerlad@hsr.ch</a>></span><br><=
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>+1 for composability instead of proliferation...</di=
v><div><br></div><div>Do we have boost's counting iterator adapter in c=
++14 or library TS?<br><br>Sent from Peter Sommerlad's<span>=A0iPad</sp=
an></div>
<div><div class=3D"h5"><div><br>On 09.10.2013, at 07:13, "Benjamin Lin=
dley" <<a href=3D"mailto:benjameslindley@gmail.com" target=3D"_blan=
k">benjameslindley@gmail.com</a>> wrote:<br><br></div></div></div><block=
quote type=3D"cite">
<div><div><div class=3D"h5"><div dir=3D"ltr">What about creating an iterato=
r adapter instead?=A0 One which keeps track of how many times it has been i=
ncremented?<br><br><div style=3D"background-color:rgb(250,250,250);border-c=
olor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-w=
ord">
<code><div><span style=3D"color:#008">typedef</span><span style> std</span>=
<span style=3D"color:#660">::</span><span style>istream_iterator</span><spa=
n style=3D"color:#080"><int></span><span style> base_t</span><span st=
yle=3D"color:#660">;</span><span style><br>
base_t ib</span><span style=3D"color:#660">(</span><span style>std</span><s=
pan style=3D"color:#660">::</span><span style>cin</span><span style=3D"colo=
r:#660">),</span><span style> ie</span><span style=3D"color:#660">;</span><=
span style><br>
std</span><span style=3D"color:#660">::</span><span style>counting_iterator=
</span><span style=3D"color:#080"><base_t></span><span style> b</span=
><span style=3D"color:#660">(</span><span style>ib</span><span style=3D"col=
or:#660">),</span><span style> e</span><span style=3D"color:#660">(</span><=
span style>ie</span><span style=3D"color:#660">);</span><span style><br>
</span><span style=3D"color:#008">auto</span><span style> p </span><span st=
yle=3D"color:#660">=3D</span><span style> std</span><span style=3D"color:#6=
60">::</span><span style>find_if</span><span style=3D"color:#660">(</span><=
span style>b</span><span style=3D"color:#660">,</span><span style> e</span>=
<span style=3D"color:#660">,</span><span style> pred</span><span style=3D"c=
olor:#660">);</span><span style><br>
std</span><span style=3D"color:#660">::</span><span style>cout </span><span=
style=3D"color:#660"><<</span><span style> p</span><span style=3D"co=
lor:#660">.</span><span style>count</span><span style=3D"color:#660">();</s=
pan><span style><br>
</span></div></code></div><br>Then you could apply it to other algorithms b=
esides find/find_if.<br><br>On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=
=E9my Lefevre wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"background-color:rgb(250,250,250);border-c=
olor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-w=
ord">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style> </span><span style=3D"color:rgb(102,102,0)"><</span=
><var><span style=3D"color:rgb(0,0,136)">class</span></var><span style> </s=
pan><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style> </span><var><span style=3D"colo=
r:rgb(0,0,136)">class</span></var><span style> </span><span style=3D"color:=
rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)">&=
gt;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an style> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</=
span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=
=3D"color:rgb(102,102,0)">><u></u>::</span><span style>difference_type<b=
r>
=A0 =A0 count_while </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span style> first</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style> </span><span =
style=3D"color:rgb(102,0,102)">InputIterator</span><span style> </span><spa=
n style=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style> </span><span style=3D"color:rgb(102,0,102)">UnaryP=
redicate</span><span style> pred</span><span style=3D"color:rgb(102,102,0)"=
>)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br>=A0 </s=
pan><var><span style=3D"color:rgb(0,0,136)">typename</span></var><span styl=
e> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><s=
pan style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color=
:rgb(102,102,0)">><u></u>::</span><span style>difference_type ret </span=
><span style=3D"color:rgb(102,102,0)">=3D</span><span style> </span><span s=
tyle=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">=
;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span =
style> </span><span style=3D"color:rgb(102,102,0)">(</span><span style>firs=
t</span><span style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"colo=
r:rgb(0,0,136)">last</span><var><span style> </span><span style=3D"color:rg=
b(102,102,0)">&&</span><span style> </span></var><var></var><span s=
tyle>pred</span><span style=3D"color:rgb(102,102,0)">(*</span><span style>f=
irst</span><span style=3D"color:rgb(102,102,0)">))</span><span style> </spa=
n><span style=3D"color:rgb(102,102,0)">{</span><span style><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>re=
t</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>=A0 =
=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>first<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br>=A0=
</span><var><span style=3D"color:rgb(0,0,136)">return</span></var><span st=
yle> ret</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br=
>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span style> </span><span style=3D"color:rgb(102,102,0)"><</span=
><var><span style=3D"color:rgb(0,0,136)">class</span></var><span style> </s=
pan><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style> </span><var><span style=3D"colo=
r:rgb(0,0,136)">class</span></var><span style> </span><span style=3D"color:=
rgb(102,0,102)">UnaryPredicate</span><span style=3D"color:rgb(102,102,0)">&=
gt;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an style> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</=
span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=
=3D"color:rgb(102,102,0)">><u></u>::</span><span style>difference_type<b=
r>
=A0 =A0 count_until </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span style> first</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style> </span><span =
style=3D"color:rgb(102,0,102)">InputIterator</span><span style> </span><spa=
n style=3D"color:rgb(0,0,136)">last</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style> </span><span style=3D"color:rgb(102,0,102)">UnaryP=
redicate</span><span style> pred</span><span style=3D"color:rgb(102,102,0)"=
>)</span><span style><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span style><br><code><=
pre><code><span style>=A0 </span><var><span style=3D"color:rgb(0,0,136)">ty=
pename</span></var><span style> iterator_traits</span><span style=3D"color:=
rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)">InputIterat=
or</span><span style=3D"color:rgb(102,102,0)">><u></u>::</span><span sty=
le>difference_type ret </span><span style=3D"color:rgb(102,102,0)">=3D</spa=
n><span style> </span><span style=3D"color:rgb(0,102,102)">0</span><span st=
yle=3D"color:rgb(102,102,0)">;</span><span style><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span =
style> </span><span style=3D"color:rgb(102,102,0)">(</span><span style>firs=
t</span><span style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"colo=
r:rgb(0,0,136)">last</span><var><span style> </span><span style=3D"color:rg=
b(102,102,0)">&&</span><span style> </span></var><var></var><span s=
tyle>!pred</span><span style=3D"color:rgb(102,102,0)">(*</span><span style>=
first</span><span style=3D"color:rgb(102,102,0)">))</span><span style> </sp=
an><span style=3D"color:rgb(102,102,0)">{</span><span style><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>re=
t</span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>=A0 =
=A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span style>first<=
/span><span style=3D"color:rgb(102,102,0)">;</span><span style><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span style><br>=A0=
</span><var><span style=3D"color:rgb(0,0,136)">return</span></var><span st=
yle> ret;<br>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span style></span><span style=3D"color:rgb(102,102,0)"></=
span></code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br>
=A0<br>
--- <br></div></div>
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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<div class=3D"im"><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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--bcaec53f346f9aff1804e84b19da--
.
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Wed, 9 Oct 2013 13:13:44 +0200
Raw View
--089e011777afdbcbf604e84cfc84
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Furthermore, the counting_iterator doesn't always work. For example, if
find/find_if reaches the end of the range, the behavior is to return the
iterator named "last" passed in argument. But this iterator has not been
incremented by the algorithm and its counter is set to 0 instead of the
distance between first and last, leading to a wrong result.
2013/10/9 R=E9my Lefevre <lefevreremy@gmail.com>
> Good point for a counting iterator ! Unfortunately, the one in boost
> library doesn't fit our need here and I am not aware of any counting
> iterator in C++14.
>
>
> 2013/10/9 Peter Sommerlad <Peter.Sommerlad@hsr.ch>
>
>> +1 for composability instead of proliferation...
>>
>> Do we have boost's counting iterator adapter in c++14 or library TS?
>>
>> Sent from Peter Sommerlad's iPad
>>
>> On 09.10.2013, at 07:13, "Benjamin Lindley" <benjameslindley@gmail.com>
>> wrote:
>>
>> What about creating an iterator adapter instead? One which keeps track
>> of how many times it has been incremented?
>>
>> typedef std::istream_iterator<int> base_t;
>> base_t ib(std::cin), ie;
>> std::counting_iterator<base_t> b(ib), e(ie);
>> auto p =3D std::find_if(b, e, pred);
>> std::cout << p.count();
>>
>> Then you could apply it to other algorithms besides find/find_if.
>>
>> On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre wrote:
>>>
>>> Hi,
>>>
>>> I thought about two new algorithms, that could be named "count_while"
>>> and "count_until". Here are their behavior:
>>>
>>> template <class InputIterator, class UnaryPredicate>
>>>
>>>
>>>
>>>
>>> typename iterator_traits<InputIterator>**::difference_type
>>>
>>>
>>>
>>>
>>> count_while (InputIterator first, InputIterator last, UnaryPredicat=
e pred)
>>>
>>>
>>>
>>> {
>>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0;
>>>
>>>
>>>
>>>
>>> while (first!=3Dlast && pred(*first)) {
>>>
>>>
>>>
>>>
>>> ++ret;
>>> ++first;
>>>
>>>
>>>
>>>
>>> }
>>> return ret;
>>>
>>> }
>>>
>>>
>>> template <class InputIterator, class UnaryPredicate>
>>>
>>>
>>>
>>>
>>> typename iterator_traits<InputIterator>**::difference_type
>>>
>>>
>>>
>>>
>>> count_until (InputIterator first, InputIterator last, UnaryPredicat=
e pred)
>>>
>>>
>>>
>>> {
>>>
>>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0;
>>>
>>>
>>>
>>>
>>> while (first!=3Dlast && !pred(*first)) {
>>>
>>>
>>>
>>>
>>> ++ret;
>>> ++first;
>>>
>>>
>>>
>>>
>>> }
>>> return ret;
>>>
>>>
>>> }
>>>
>>>
>>> What do you think about adding these two components to the algorithms
>>> library ?
>>>
>> --
>>
>> ---
>> 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.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--089e011777afdbcbf604e84cfc84
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Furthermore, the counting_iterator doesn't always work=
.. For example, if find/find_if reaches the end of the range, the behavior i=
s to return the iterator named "last" passed in argument. But thi=
s iterator has not been incremented by the algorithm and its counter is set=
to 0 instead of the distance between first and last, leading to a wrong re=
sult.<br>
</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2013/10=
/9 R=E9my Lefevre <span dir=3D"ltr"><<a href=3D"mailto:lefevreremy@gmail=
..com" target=3D"_blank">lefevreremy@gmail.com</a>></span><br><blockquote=
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex">
<div dir=3D"ltr">Good point for a counting iterator ! Unfortunately, the on=
e in boost library doesn't fit our need here and I am not aware of any =
counting iterator in C++14.<br></div><div class=3D"HOEnZb"><div class=3D"h5=
">
<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">
2013/10/9 Peter Sommerlad <span dir=3D"ltr"><<a href=3D"mailto:Peter.Som=
merlad@hsr.ch" target=3D"_blank">Peter.Sommerlad@hsr.ch</a>></span><br><=
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>+1 for composability instead of proliferation...</di=
v><div><br></div><div>Do we have boost's counting iterator adapter in c=
++14 or library TS?<br><br>Sent from Peter Sommerlad's<span>=A0iPad</sp=
an></div>
<div><div><div><br>On 09.10.2013, at 07:13, "Benjamin Lindley" &l=
t;<a href=3D"mailto:benjameslindley@gmail.com" target=3D"_blank">benjamesli=
ndley@gmail.com</a>> wrote:<br><br></div></div></div><blockquote type=3D=
"cite">
<div><div><div><div dir=3D"ltr">What about creating an iterator adapter ins=
tead?=A0 One which keeps track of how many times it has been incremented?<b=
r><br><div 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><div><span style=3D"color:#008">typedef</span><span> std</span><span =
style=3D"color:#660">::</span><span>istream_iterator</span><span style=3D"c=
olor:#080"><int></span><span> base_t</span><span style=3D"color:#660"=
>;</span><span><br>
base_t ib</span><span style=3D"color:#660">(</span><span>std</span><span st=
yle=3D"color:#660">::</span><span>cin</span><span style=3D"color:#660">),</=
span><span> ie</span><span style=3D"color:#660">;</span><span><br>
std</span><span style=3D"color:#660">::</span><span>counting_iterator</span=
><span style=3D"color:#080"><base_t></span><span> b</span><span style=
=3D"color:#660">(</span><span>ib</span><span style=3D"color:#660">),</span>=
<span> e</span><span style=3D"color:#660">(</span><span>ie</span><span styl=
e=3D"color:#660">);</span><span><br>
</span><span style=3D"color:#008">auto</span><span> p </span><span style=3D=
"color:#660">=3D</span><span> std</span><span style=3D"color:#660">::</span=
><span>find_if</span><span style=3D"color:#660">(</span><span>b</span><span=
style=3D"color:#660">,</span><span> e</span><span style=3D"color:#660">,</=
span><span> pred</span><span style=3D"color:#660">);</span><span><br>
std</span><span style=3D"color:#660">::</span><span>cout </span><span style=
=3D"color:#660"><<</span><span> p</span><span style=3D"color:#660">.<=
/span><span>count</span><span style=3D"color:#660">();</span><span><br>
</span></div></code></div><br>Then you could apply it to other algorithms b=
esides find/find_if.<br><br>On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=
=E9my Lefevre wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"background-color:rgb(250,250,250);border-c=
olor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-w=
ord">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span> </span><span style=3D"color:rgb(102,102,0)"><</span><var>=
<span style=3D"color:rgb(0,0,136)">class</span></var><span> </span><span st=
yle=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span> </span><var><span style=3D"color:rgb(0,0,136)">cl=
ass</span></var><span> </span><span style=3D"color:rgb(102,0,102)">UnaryPre=
dicate</span><span style=3D"color:rgb(102,102,0)">></span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><=
span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"colo=
r:rgb(102,102,0)">><u></u>::</span><span>difference_type<br>
=A0 =A0 count_while </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span> first</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"col=
or:rgb(102,0,102)">InputIterator</span><span> </span><span style=3D"color:r=
gb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,</span><span>=
</span><span style=3D"color:rgb(102,0,102)">UnaryPredicate</span><span> pr=
ed</span><span style=3D"color:rgb(102,102,0)">)</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span><br>=A0 </span><v=
ar><span style=3D"color:rgb(0,0,136)">typename</span></var><span> iterator_=
traits</span><span style=3D"color:rgb(102,102,0)"><</span><span style=3D=
"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(102,102=
,0)">><u></u>::</span><span>difference_type ret </span><span style=3D"co=
lor:rgb(102,102,0)">=3D</span><span> </span><span style=3D"color:rgb(0,102,=
102)">0</span><span style=3D"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span>=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>first</span><spa=
n style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,13=
6)">last</span><var><span> </span><span style=3D"color:rgb(102,102,0)">&=
;&</span><span> </span></var><var></var><span>pred</span><span style=3D=
"color:rgb(102,102,0)">(*</span><span>first</span><span style=3D"color:rgb(=
102,102,0)">))</span><span> </span><span style=3D"color:rgb(102,102,0)">{</=
span><span><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span>ret</spa=
n><span style=3D"color:rgb(102,102,0)">;</span><span><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(102,102,0)">++</span><span>first</span><span style=3D=
"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br>=A0 </spa=
n><var><span style=3D"color:rgb(0,0,136)">return</span></var><span> ret</sp=
an><span style=3D"color:rgb(102,102,0)">;</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"background-color:rgb(250,250,250);border-color:r=
gb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span> </span><span style=3D"color:rgb(102,102,0)"><</span><var>=
<span style=3D"color:rgb(0,0,136)">class</span></var><span> </span><span st=
yle=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span> </span><var><span style=3D"color:rgb(0,0,136)">cl=
ass</span></var><span> </span><span style=3D"color:rgb(102,0,102)">UnaryPre=
dicate</span><span style=3D"color:rgb(102,102,0)">></span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><=
span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"colo=
r:rgb(102,102,0)">><u></u>::</span><span>difference_type<br>
=A0 =A0 count_until </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span> first</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"col=
or:rgb(102,0,102)">InputIterator</span><span> </span><span style=3D"color:r=
gb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,</span><span>=
</span><span style=3D"color:rgb(102,0,102)">UnaryPredicate</span><span> pr=
ed</span><span style=3D"color:rgb(102,102,0)">)</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span><br><code><pre><c=
ode><span>=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span=
></var><span> iterator_traits</span><span style=3D"color:rgb(102,102,0)">&l=
t;</span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span sty=
le=3D"color:rgb(102,102,0)">><u></u>::</span><span>difference_type ret <=
/span><span style=3D"color:rgb(102,102,0)">=3D</span><span> </span><span st=
yle=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">;=
</span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span>=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>first</span><spa=
n style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,13=
6)">last</span><var><span> </span><span style=3D"color:rgb(102,102,0)">&=
;&</span><span> </span></var><var></var><span>!pred</span><span style=
=3D"color:rgb(102,102,0)">(*</span><span>first</span><span style=3D"color:r=
gb(102,102,0)">))</span><span> </span><span style=3D"color:rgb(102,102,0)">=
{</span><span><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span>ret</spa=
n><span style=3D"color:rgb(102,102,0)">;</span><span><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(102,102,0)">++</span><span>first</span><span style=3D=
"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br>=A0 </spa=
n><var><span style=3D"color:rgb(0,0,136)">return</span></var><span> ret;<br=
>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span></span><span style=3D"color:rgb(102,102,0)"></span><=
/code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br>
=A0<br>
--- <br></div></div>
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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<div><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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><div><div>
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--089e011777afdbcbf604e84cfc84--
.
Author: "Billy O'Neal" <billy.oneal@gmail.com>
Date: Wed, 9 Oct 2013 07:07:25 -0700
Raw View
--047d7bd76d1e24bcec04e84f6afc
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On the other hand, it is typically trivial to initialize "last" with the
count of the container to which it points. (Depending on the container)
Billy O'Neal
https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
http://stackoverflow.com/users/82320/billy-oneal
Malware Response Instructor - BleepingComputer.com
On Wed, Oct 9, 2013 at 4:13 AM, R=E9my Lefevre <lefevreremy@gmail.com> wrot=
e:
> Furthermore, the counting_iterator doesn't always work. For example, if
> find/find_if reaches the end of the range, the behavior is to return the
> iterator named "last" passed in argument. But this iterator has not been
> incremented by the algorithm and its counter is set to 0 instead of the
> distance between first and last, leading to a wrong result.
>
>
> 2013/10/9 R=E9my Lefevre <lefevreremy@gmail.com>
>
>> Good point for a counting iterator ! Unfortunately, the one in boost
>> library doesn't fit our need here and I am not aware of any counting
>> iterator in C++14.
>>
>>
>> 2013/10/9 Peter Sommerlad <Peter.Sommerlad@hsr.ch>
>>
>>> +1 for composability instead of proliferation...
>>>
>>> Do we have boost's counting iterator adapter in c++14 or library TS?
>>>
>>> Sent from Peter Sommerlad's iPad
>>>
>>> On 09.10.2013, at 07:13, "Benjamin Lindley" <benjameslindley@gmail.com>
>>> wrote:
>>>
>>> What about creating an iterator adapter instead? One which keeps track
>>> of how many times it has been incremented?
>>>
>>> typedef std::istream_iterator<int> base_t;
>>> base_t ib(std::cin), ie;
>>> std::counting_iterator<base_t> b(ib), e(ie);
>>> auto p =3D std::find_if(b, e, pred);
>>> std::cout << p.count();
>>>
>>> Then you could apply it to other algorithms besides find/find_if.
>>>
>>> On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre wrote:
>>>>
>>>> Hi,
>>>>
>>>> I thought about two new algorithms, that could be named "count_while"
>>>> and "count_until". Here are their behavior:
>>>>
>>>> template <class InputIterator, class UnaryPredicate>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> typename iterator_traits<InputIterator>**::difference_type
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> count_while (InputIterator first, InputIterator last, UnaryPredica=
te pred)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> {
>>>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0=
;
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> while (first!=3Dlast && pred(*first)) {
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ++ret;
>>>> ++first;
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> }
>>>> return ret;
>>>>
>>>> }
>>>>
>>>>
>>>> template <class InputIterator, class UnaryPredicate>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> typename iterator_traits<InputIterator>**::difference_type
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> count_until (InputIterator first, InputIterator last, UnaryPredica=
te pred)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> {
>>>>
>>>> typename iterator_traits<InputIterator>**::difference_type ret =3D 0=
;
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> while (first!=3Dlast && !pred(*first)) {
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ++ret;
>>>> ++first;
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> }
>>>> return ret;
>>>>
>>>>
>>>> }
>>>>
>>>>
>>>> What do you think about adding these two components to the algorithms
>>>> 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.
>>> Visit this group at
>>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59=
c/unsubscribe
>>> .
>>> To unsubscribe from this group and all its topics, send an email to
>>> std-proposals+unsubscribe@isocpp.org.
>>> To post to this group, send email to std-proposals@isocpp.org.
>>> Visit this group at
>>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>>
>>
>>
> --
>
> ---
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--047d7bd76d1e24bcec04e84f6afc
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On the other hand, it is typically trivial to initialize &=
quot;last" with the count of the container to which it points. (Depend=
ing on the container)</div><div class=3D"gmail_extra"><br clear=3D"all"><di=
v><div dir=3D"ltr">
<div>Billy O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal=
/" target=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=
=3D"http://stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">htt=
p://stackoverflow.com/users/82320/billy-oneal</a></div>
<div>Malware Response Instructor - BleepingComputer.com</div></div></div>
<br><br><div class=3D"gmail_quote">On Wed, Oct 9, 2013 at 4:13 AM, R=E9my L=
efevre <span dir=3D"ltr"><<a href=3D"mailto:lefevreremy@gmail.com" targe=
t=3D"_blank">lefevreremy@gmail.com</a>></span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex">
<div dir=3D"ltr">Furthermore, the counting_iterator doesn't always work=
.. For example, if find/find_if reaches the end of the range, the behavior i=
s to return the iterator named "last" passed in argument. But thi=
s iterator has not been incremented by the algorithm and its counter is set=
to 0 instead of the distance between first and last, leading to a wrong re=
sult.<br>
</div><div class=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_extra"><b=
r><br><div class=3D"gmail_quote">2013/10/9 R=E9my Lefevre <span dir=3D"ltr"=
><<a href=3D"mailto:lefevreremy@gmail.com" target=3D"_blank">lefevreremy=
@gmail.com</a>></span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid">
<div dir=3D"ltr">Good point for a counting iterator ! Unfortunately, the on=
e in boost library doesn't fit our need here and I am not aware of any =
counting iterator in C++14.<br></div><div><div>
<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">
2013/10/9 Peter Sommerlad <span dir=3D"ltr"><<a href=3D"mailto:Peter.Som=
merlad@hsr.ch" target=3D"_blank">Peter.Sommerlad@hsr.ch</a>></span><br><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-=
left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-le=
ft-style:solid">
<div dir=3D"auto"><div>+1 for composability instead of proliferation...</di=
v><div><br></div><div>Do we have boost's counting iterator adapter in c=
++14 or library TS?<br><br>Sent from Peter Sommerlad's<span>=A0iPad</sp=
an></div>
<div><div><div><br>On 09.10.2013, at 07:13, "Benjamin Lindley" &l=
t;<a href=3D"mailto:benjameslindley@gmail.com" target=3D"_blank">benjamesli=
ndley@gmail.com</a>> wrote:<br><br></div></div></div><blockquote type=3D=
"cite">
<div><div><div><div dir=3D"ltr">What about creating an iterator adapter ins=
tead?=A0 One which keeps track of how many times it has been incremented?<b=
r><br><div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(=
250,250,250)">
<code><div><span style=3D"color:rgb(0,0,136)">typedef</span><span> std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span>istream_iterator</spa=
n><span style=3D"color:rgb(0,136,0)"><int></span><span> base_t</span>=
<span style=3D"color:rgb(102,102,0)">;</span><span><br>
base_t ib</span><span style=3D"color:rgb(102,102,0)">(</span><span>std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span>cin</span><span style=
=3D"color:rgb(102,102,0)">),</span><span> ie</span><span style=3D"color:rgb=
(102,102,0)">;</span><span><br>
std</span><span style=3D"color:rgb(102,102,0)">::</span><span>counting_iter=
ator</span><span style=3D"color:rgb(0,136,0)"><base_t></span><span> b=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>ib</span><span st=
yle=3D"color:rgb(102,102,0)">),</span><span> e</span><span style=3D"color:r=
gb(102,102,0)">(</span><span>ie</span><span style=3D"color:rgb(102,102,0)">=
);</span><span><br>
</span><span style=3D"color:rgb(0,0,136)">auto</span><span> p </span><span =
style=3D"color:rgb(102,102,0)">=3D</span><span> std</span><span style=3D"co=
lor:rgb(102,102,0)">::</span><span>find_if</span><span style=3D"color:rgb(1=
02,102,0)">(</span><span>b</span><span style=3D"color:rgb(102,102,0)">,</sp=
an><span> e</span><span style=3D"color:rgb(102,102,0)">,</span><span> pred<=
/span><span style=3D"color:rgb(102,102,0)">);</span><span><br>
std</span><span style=3D"color:rgb(102,102,0)">::</span><span>cout </span><=
span style=3D"color:rgb(102,102,0)"><<</span><span> p</span><span sty=
le=3D"color:rgb(102,102,0)">.</span><span>count</span><span style=3D"color:=
rgb(102,102,0)">();</span><span><br>
</span></div></code></div><br>Then you could apply it to other algorithms b=
esides find/find_if.<br><br>On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=
=E9my Lefevre wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-lef=
t-width:1px;border-left-style:solid">
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"border:1px solid rgb(187,187,187);backgrou=
nd-color:rgb(250,250,250)">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span> </span><span style=3D"color:rgb(102,102,0)"><</span><var>=
<span style=3D"color:rgb(0,0,136)">class</span></var><span> </span><span st=
yle=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span> </span><var><span style=3D"color:rgb(0,0,136)">cl=
ass</span></var><span> </span><span style=3D"color:rgb(102,0,102)">UnaryPre=
dicate</span><span style=3D"color:rgb(102,102,0)">></span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><=
span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"colo=
r:rgb(102,102,0)">><u></u>::</span><span>difference_type<br>
=A0 =A0 count_while </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span> first</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"col=
or:rgb(102,0,102)">InputIterator</span><span> </span><span style=3D"color:r=
gb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,</span><span>=
</span><span style=3D"color:rgb(102,0,102)">UnaryPredicate</span><span> pr=
ed</span><span style=3D"color:rgb(102,102,0)">)</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span><br>=A0 </span><v=
ar><span style=3D"color:rgb(0,0,136)">typename</span></var><span> iterator_=
traits</span><span style=3D"color:rgb(102,102,0)"><</span><span style=3D=
"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(102,102=
,0)">><u></u>::</span><span>difference_type ret </span><span style=3D"co=
lor:rgb(102,102,0)">=3D</span><span> </span><span style=3D"color:rgb(0,102,=
102)">0</span><span style=3D"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span>=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>first</span><spa=
n style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,13=
6)">last</span><var><span> </span><span style=3D"color:rgb(102,102,0)">&=
;&</span><span> </span></var><var></var><span>pred</span><span style=3D=
"color:rgb(102,102,0)">(*</span><span>first</span><span style=3D"color:rgb(=
102,102,0)">))</span><span> </span><span style=3D"color:rgb(102,102,0)">{</=
span><span><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span>ret</spa=
n><span style=3D"color:rgb(102,102,0)">;</span><span><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(102,102,0)">++</span><span>first</span><span style=3D=
"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br>=A0 </spa=
n><var><span style=3D"color:rgb(0,0,136)">return</span></var><span> ret</sp=
an><span style=3D"color:rgb(102,102,0)">;</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"border:1px solid rgb(187,187,187);background-col=
or:rgb(250,250,250)">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span> </span><span style=3D"color:rgb(102,102,0)"><</span><var>=
<span style=3D"color:rgb(0,0,136)">class</span></var><span> </span><span st=
yle=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span> </span><var><span style=3D"color:rgb(0,0,136)">cl=
ass</span></var><span> </span><span style=3D"color:rgb(102,0,102)">UnaryPre=
dicate</span><span style=3D"color:rgb(102,102,0)">></span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><=
span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"colo=
r:rgb(102,102,0)">><u></u>::</span><span>difference_type<br>
=A0 =A0 count_until </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span> first</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"col=
or:rgb(102,0,102)">InputIterator</span><span> </span><span style=3D"color:r=
gb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,</span><span>=
</span><span style=3D"color:rgb(102,0,102)">UnaryPredicate</span><span> pr=
ed</span><span style=3D"color:rgb(102,102,0)">)</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span><br><code><pre><c=
ode><span>=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span=
></var><span> iterator_traits</span><span style=3D"color:rgb(102,102,0)">&l=
t;</span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span sty=
le=3D"color:rgb(102,102,0)">><u></u>::</span><span>difference_type ret <=
/span><span style=3D"color:rgb(102,102,0)">=3D</span><span> </span><span st=
yle=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">;=
</span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span>=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>first</span><spa=
n style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,13=
6)">last</span><var><span> </span><span style=3D"color:rgb(102,102,0)">&=
;&</span><span> </span></var><var></var><span>!pred</span><span style=
=3D"color:rgb(102,102,0)">(*</span><span>first</span><span style=3D"color:r=
gb(102,102,0)">))</span><span> </span><span style=3D"color:rgb(102,102,0)">=
{</span><span><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span>ret</spa=
n><span style=3D"color:rgb(102,102,0)">;</span><span><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(102,102,0)">++</span><span>first</span><span style=3D=
"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br>=A0 </spa=
n><var><span style=3D"color:rgb(0,0,136)">return</span></var><span> ret;<br=
>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span></span><span style=3D"color:rgb(102,102,0)"></span><=
/code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br>
=A0<br>
--- <br></div></div>
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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<div><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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><div><div>
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
<p></p>
-- <br>
=A0<br>
--- <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%2Bunsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bd76d1e24bcec04e84f6afc--
.
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Wed, 9 Oct 2013 16:30:49 +0200
Raw View
--047d7bfced1eb3b0b604e84fbdf9
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
First it depends on the container. For example, the complexity of
determining the size of a forward_list is linear in its size. Furthermore,
you don't have necessarily a container. For example, with istream_iterator.
In this case, there is no way to predict the distance between the beginning
of the input stream and its end.
2013/10/9 Billy O'Neal <billy.oneal@gmail.com>
> On the other hand, it is typically trivial to initialize "last" with the
> count of the container to which it points. (Depending on the container)
>
> Billy O'Neal
> https://github.com/BillyONeal/ <https://bitbucket.org/BillyONeal/>
> http://stackoverflow.com/users/82320/billy-oneal
> Malware Response Instructor - BleepingComputer.com
>
>
> On Wed, Oct 9, 2013 at 4:13 AM, R=E9my Lefevre <lefevreremy@gmail.com>wro=
te:
>
>> Furthermore, the counting_iterator doesn't always work. For example, if
>> find/find_if reaches the end of the range, the behavior is to return the
>> iterator named "last" passed in argument. But this iterator has not been
>> incremented by the algorithm and its counter is set to 0 instead of the
>> distance between first and last, leading to a wrong result.
>>
>>
>> 2013/10/9 R=E9my Lefevre <lefevreremy@gmail.com>
>>
>>> Good point for a counting iterator ! Unfortunately, the one in boost
>>> library doesn't fit our need here and I am not aware of any counting
>>> iterator in C++14.
>>>
>>>
>>> 2013/10/9 Peter Sommerlad <Peter.Sommerlad@hsr.ch>
>>>
>>>> +1 for composability instead of proliferation...
>>>>
>>>> Do we have boost's counting iterator adapter in c++14 or library TS?
>>>>
>>>> Sent from Peter Sommerlad's iPad
>>>>
>>>> On 09.10.2013, at 07:13, "Benjamin Lindley" <benjameslindley@gmail.com=
>
>>>> wrote:
>>>>
>>>> What about creating an iterator adapter instead? One which keeps trac=
k
>>>> of how many times it has been incremented?
>>>>
>>>> typedef std::istream_iterator<int> base_t;
>>>> base_t ib(std::cin), ie;
>>>> std::counting_iterator<base_t> b(ib), e(ie);
>>>> auto p =3D std::find_if(b, e, pred);
>>>> std::cout << p.count();
>>>>
>>>> Then you could apply it to other algorithms besides find/find_if.
>>>>
>>>> On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=E9my Lefevre wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I thought about two new algorithms, that could be named "count_while"
>>>>> and "count_until". Here are their behavior:
>>>>>
>>>>> template <class InputIterator, class UnaryPredicate>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> typename iterator_traits<InputIterator>**::difference_type
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> count_while (InputIterator first, InputIterator last, UnaryPredic=
ate pred)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> {
>>>>> typename iterator_traits<InputIterator>**::difference_type ret =3D =
0;
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> while (first!=3Dlast && pred(*first)) {
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ++ret;
>>>>> ++first;
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> }
>>>>> return ret;
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> template <class InputIterator, class UnaryPredicate>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> typename iterator_traits<InputIterator>**::difference_type
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> count_until (InputIterator first, InputIterator last, UnaryPredic=
ate pred)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> {
>>>>>
>>>>> typename iterator_traits<InputIterator>**::difference_type ret =3D =
0;
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> while (first!=3Dlast && !pred(*first)) {
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ++ret;
>>>>> ++first;
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> }
>>>>> return ret;
>>>>>
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> What do you think about adding these two components to the algorithms
>>>>> 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.
>>>> Visit this group at
>>>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>>>
>>>> --
>>>>
>>>> ---
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this topic, visit
>>>> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw5=
9c/unsubscribe
>>>> .
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> std-proposals+unsubscribe@isocpp.org.
>>>> To post to this group, send email to std-proposals@isocpp.org.
>>>> Visit this group at
>>>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>>>
>>>
>>>
>> --
>>
>> ---
>> 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.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--047d7bfced1eb3b0b604e84fbdf9
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">First it depends on the container. For example, the comple=
xity of determining the size of a forward_list is linear in its size. Furth=
ermore, you don't have necessarily a container. For example, with istre=
am_iterator. In this case, there is no way to predict the distance between =
the beginning of the input stream and its end. <br>
</div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2013/10=
/9 Billy O'Neal <span dir=3D"ltr"><<a href=3D"mailto:billy.oneal@gma=
il.com" target=3D"_blank">billy.oneal@gmail.com</a>></span><br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex">
<div dir=3D"ltr">On the other hand, it is typically trivial to initialize &=
quot;last" with the count of the container to which it points. (Depend=
ing on the container)</div><div class=3D"gmail_extra"><span class=3D"HOEnZb=
"><font color=3D"#888888"><br clear=3D"all">
<div><div dir=3D"ltr">
<div>Billy O'Neal</div><div><a href=3D"https://bitbucket.org/BillyONeal=
/" target=3D"_blank">https://github.com/BillyONeal/</a></div><div><a href=
=3D"http://stackoverflow.com/users/82320/billy-oneal" target=3D"_blank">htt=
p://stackoverflow.com/users/82320/billy-oneal</a></div>
<div>Malware Response Instructor - BleepingComputer.com</div></div></div></=
font></span><div><div class=3D"h5">
<br><br><div class=3D"gmail_quote">On Wed, Oct 9, 2013 at 4:13 AM, R=E9my L=
efevre <span dir=3D"ltr"><<a href=3D"mailto:lefevreremy@gmail.com" targe=
t=3D"_blank">lefevreremy@gmail.com</a>></span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex">
<div dir=3D"ltr">Furthermore, the counting_iterator doesn't always work=
.. For example, if find/find_if reaches the end of the range, the behavior i=
s to return the iterator named "last" passed in argument. But thi=
s iterator has not been incremented by the algorithm and its counter is set=
to 0 instead of the distance between first and last, leading to a wrong re=
sult.<br>
</div><div><div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quot=
e">2013/10/9 R=E9my Lefevre <span dir=3D"ltr"><<a href=3D"mailto:lefevre=
remy@gmail.com" target=3D"_blank">lefevreremy@gmail.com</a>></span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid">
<div dir=3D"ltr">Good point for a counting iterator ! Unfortunately, the on=
e in boost library doesn't fit our need here and I am not aware of any =
counting iterator in C++14.<br></div><div><div>
<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">
2013/10/9 Peter Sommerlad <span dir=3D"ltr"><<a href=3D"mailto:Peter.Som=
merlad@hsr.ch" target=3D"_blank">Peter.Sommerlad@hsr.ch</a>></span><br><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-=
left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-le=
ft-style:solid">
<div dir=3D"auto"><div>+1 for composability instead of proliferation...</di=
v><div><br></div><div>Do we have boost's counting iterator adapter in c=
++14 or library TS?<br><br>Sent from Peter Sommerlad's<span>=A0iPad</sp=
an></div>
<div><div><div><br>On 09.10.2013, at 07:13, "Benjamin Lindley" &l=
t;<a href=3D"mailto:benjameslindley@gmail.com" target=3D"_blank">benjamesli=
ndley@gmail.com</a>> wrote:<br><br></div></div></div><blockquote type=3D=
"cite">
<div><div><div><div dir=3D"ltr">What about creating an iterator adapter ins=
tead?=A0 One which keeps track of how many times it has been incremented?<b=
r><br><div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(=
250,250,250)">
<code><div><span style=3D"color:rgb(0,0,136)">typedef</span><span> std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span>istream_iterator</spa=
n><span style=3D"color:rgb(0,136,0)"><int></span><span> base_t</span>=
<span style=3D"color:rgb(102,102,0)">;</span><span><br>
base_t ib</span><span style=3D"color:rgb(102,102,0)">(</span><span>std</spa=
n><span style=3D"color:rgb(102,102,0)">::</span><span>cin</span><span style=
=3D"color:rgb(102,102,0)">),</span><span> ie</span><span style=3D"color:rgb=
(102,102,0)">;</span><span><br>
std</span><span style=3D"color:rgb(102,102,0)">::</span><span>counting_iter=
ator</span><span style=3D"color:rgb(0,136,0)"><base_t></span><span> b=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>ib</span><span st=
yle=3D"color:rgb(102,102,0)">),</span><span> e</span><span style=3D"color:r=
gb(102,102,0)">(</span><span>ie</span><span style=3D"color:rgb(102,102,0)">=
);</span><span><br>
</span><span style=3D"color:rgb(0,0,136)">auto</span><span> p </span><span =
style=3D"color:rgb(102,102,0)">=3D</span><span> std</span><span style=3D"co=
lor:rgb(102,102,0)">::</span><span>find_if</span><span style=3D"color:rgb(1=
02,102,0)">(</span><span>b</span><span style=3D"color:rgb(102,102,0)">,</sp=
an><span> e</span><span style=3D"color:rgb(102,102,0)">,</span><span> pred<=
/span><span style=3D"color:rgb(102,102,0)">);</span><span><br>
std</span><span style=3D"color:rgb(102,102,0)">::</span><span>cout </span><=
span style=3D"color:rgb(102,102,0)"><<</span><span> p</span><span sty=
le=3D"color:rgb(102,102,0)">.</span><span>count</span><span style=3D"color:=
rgb(102,102,0)">();</span><span><br>
</span></div></code></div><br>Then you could apply it to other algorithms b=
esides find/find_if.<br><br>On Tuesday, October 8, 2013 3:04:23 PM UTC-5, R=
=E9my Lefevre wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-lef=
t-width:1px;border-left-style:solid">
<div dir=3D"ltr">Hi,<br><br>I thought about two new algorithms, that could =
be named "count_while" and "count_until". Here are thei=
r behavior:<br><br><div style=3D"border:1px solid rgb(187,187,187);backgrou=
nd-color:rgb(250,250,250)">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span> </span><span style=3D"color:rgb(102,102,0)"><</span><var>=
<span style=3D"color:rgb(0,0,136)">class</span></var><span> </span><span st=
yle=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span> </span><var><span style=3D"color:rgb(0,0,136)">cl=
ass</span></var><span> </span><span style=3D"color:rgb(102,0,102)">UnaryPre=
dicate</span><span style=3D"color:rgb(102,102,0)">></span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><=
span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"colo=
r:rgb(102,102,0)">><u></u>::</span><span>difference_type<br>
=A0 =A0 count_while </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span> first</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"col=
or:rgb(102,0,102)">InputIterator</span><span> </span><span style=3D"color:r=
gb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,</span><span>=
</span><span style=3D"color:rgb(102,0,102)">UnaryPredicate</span><span> pr=
ed</span><span style=3D"color:rgb(102,102,0)">)</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span><br>=A0 </span><v=
ar><span style=3D"color:rgb(0,0,136)">typename</span></var><span> iterator_=
traits</span><span style=3D"color:rgb(102,102,0)"><</span><span style=3D=
"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(102,102=
,0)">><u></u>::</span><span>difference_type ret </span><span style=3D"co=
lor:rgb(102,102,0)">=3D</span><span> </span><span style=3D"color:rgb(0,102,=
102)">0</span><span style=3D"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span>=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>first</span><spa=
n style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,13=
6)">last</span><var><span> </span><span style=3D"color:rgb(102,102,0)">&=
;&</span><span> </span></var><var></var><span>pred</span><span style=3D=
"color:rgb(102,102,0)">(*</span><span>first</span><span style=3D"color:rgb(=
102,102,0)">))</span><span> </span><span style=3D"color:rgb(102,102,0)">{</=
span><span><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span>ret</spa=
n><span style=3D"color:rgb(102,102,0)">;</span><span><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(102,102,0)">++</span><span>first</span><span style=3D=
"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br>=A0 </spa=
n><var><span style=3D"color:rgb(0,0,136)">return</span></var><span> ret</sp=
an><span style=3D"color:rgb(102,102,0)">;</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">}</span></code></pre></div></co=
de></div><br><div style=3D"border:1px solid rgb(187,187,187);background-col=
or:rgb(250,250,250)">
<code><div><pre><code><var><span style=3D"color:rgb(0,0,136)">template</spa=
n></var><span> </span><span style=3D"color:rgb(102,102,0)"><</span><var>=
<span style=3D"color:rgb(0,0,136)">class</span></var><span> </span><span st=
yle=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"color:rgb(1=
02,102,0)">,</span><span> </span><var><span style=3D"color:rgb(0,0,136)">cl=
ass</span></var><span> </span><span style=3D"color:rgb(102,0,102)">UnaryPre=
dicate</span><span style=3D"color:rgb(102,102,0)">></span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span></var><sp=
an> iterator_traits</span><span style=3D"color:rgb(102,102,0)"><</span><=
span style=3D"color:rgb(102,0,102)">InputIterator</span><span style=3D"colo=
r:rgb(102,102,0)">><u></u>::</span><span>difference_type<br>
=A0 =A0 count_until </span><span style=3D"color:rgb(102,102,0)">(</span><sp=
an style=3D"color:rgb(102,0,102)">InputIterator</span><span> first</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span> </span><span style=3D"col=
or:rgb(102,0,102)">InputIterator</span><span> </span><span style=3D"color:r=
gb(0,0,136)">last</span><span style=3D"color:rgb(102,102,0)">,</span><span>=
</span><span style=3D"color:rgb(102,0,102)">UnaryPredicate</span><span> pr=
ed</span><span style=3D"color:rgb(102,102,0)">)</span><span><br>
</span><span style=3D"color:rgb(102,102,0)">{</span><span><br><code><pre><c=
ode><span>=A0 </span><var><span style=3D"color:rgb(0,0,136)">typename</span=
></var><span> iterator_traits</span><span style=3D"color:rgb(102,102,0)">&l=
t;</span><span style=3D"color:rgb(102,0,102)">InputIterator</span><span sty=
le=3D"color:rgb(102,102,0)">><u></u>::</span><span>difference_type ret <=
/span><span style=3D"color:rgb(102,102,0)">=3D</span><span> </span><span st=
yle=3D"color:rgb(0,102,102)">0</span><span style=3D"color:rgb(102,102,0)">;=
</span><span><br>
=A0 </span><var><span style=3D"color:rgb(0,0,136)">while</span></var><span>=
</span><span style=3D"color:rgb(102,102,0)">(</span><span>first</span><spa=
n style=3D"color:rgb(102,102,0)">!=3D</span><span style=3D"color:rgb(0,0,13=
6)">last</span><var><span> </span><span style=3D"color:rgb(102,102,0)">&=
;&</span><span> </span></var><var></var><span>!pred</span><span style=
=3D"color:rgb(102,102,0)">(*</span><span>first</span><span style=3D"color:r=
gb(102,102,0)">))</span><span> </span><span style=3D"color:rgb(102,102,0)">=
{</span><span><br>
=A0 =A0 </span><span style=3D"color:rgb(102,102,0)">++</span><span>ret</spa=
n><span style=3D"color:rgb(102,102,0)">;</span><span><br>=A0 =A0 </span><sp=
an style=3D"color:rgb(102,102,0)">++</span><span>first</span><span style=3D=
"color:rgb(102,102,0)">;</span><span><br>
=A0 </span><span style=3D"color:rgb(102,102,0)">}</span><span><br>=A0 </spa=
n><var><span style=3D"color:rgb(0,0,136)">return</span></var><span> ret;<br=
>
}</span><span style=3D"color:rgb(102,102,0)"></span></code></pre></code></s=
pan></code><code><span></span><span style=3D"color:rgb(102,102,0)"></span><=
/code></pre></div></code></div>
<br>What do you think about adding these two components to the algorithms l=
ibrary ?</div>
</blockquote></div>
<p></p>
-- <br>
=A0<br>
--- <br></div></div>
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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<div><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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><div><div>
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
<p></p>
-- <br>
=A0<br>
--- <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%2Bunsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div></div></div><div class=3D"HOEnZb">=
<div class=3D"h5">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7bfced1eb3b0b604e84fbdf9--
.
Author: Greg Marr <gregmmarr@gmail.com>
Date: Wed, 9 Oct 2013 09:02:43 -0700 (PDT)
Raw View
------=_Part_220_21458945.1381334563966
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Tuesday, October 8, 2013 4:04:23 PM UTC-4, R=E9my Lefevre wrote:
> Hi,
>
> I thought about two new algorithms, that could be named "count_while" and=
=20
> "count_until". Here are their behavior:
>
> What do you think about adding these two components to the algorithms=20
> library ?
>
Should there be both count_while that takes a T to compare to, and=20
count_while_if that takes a predicate? That seems like it would fulfill=20
Vlad's desire to have the word _if in there to indicate that it take a=20
predicate?
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_220_21458945.1381334563966
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span style=3D"font-size: 13px;">On Tuesday, October 8, 20=
13 4:04:23 PM UTC-4, R=E9my Lefevre wrote:</span><br><blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;"><div dir=3D"ltr">Hi,<br><br>I thought about two new =
algorithms, that could be named "count_while" and "count_until". Here are t=
heir behavior:<br><br>What do you think about adding these two components t=
o the algorithms library ?</div></blockquote><div><br></div><div>Should the=
re be both count_while that takes a T to compare to, and count_while_if tha=
t takes a predicate? That seems like it would fulfill Vlad's desire t=
o have the word _if in there to indicate that it take a predicate?</div><di=
v><br></div></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_220_21458945.1381334563966--
.
Author: =?ISO-8859-1?Q?R=E9my_Lefevre?= <lefevreremy@gmail.com>
Date: Wed, 9 Oct 2013 22:59:58 +0200
Raw View
--047d7b6251b0699eb004e8552dbc
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Yes, it's maybe a (the) solution.
2013/10/9 Greg Marr <gregmmarr@gmail.com>
> On Tuesday, October 8, 2013 4:04:23 PM UTC-4, R=E9my Lefevre wrote:
>
>> Hi,
>>
>> I thought about two new algorithms, that could be named "count_while" an=
d
>> "count_until". Here are their behavior:
>>
>> What do you think about adding these two components to the algorithms
>> library ?
>>
>
> Should there be both count_while that takes a T to compare to, and
> count_while_if that takes a predicate? That seems like it would fulfill
> Vlad's desire to have the word _if in there to indicate that it take a
> predicate?
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--047d7b6251b0699eb004e8552dbc
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes, it's maybe a (the) solution.<br></div><div class=
=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2013/10/9 Greg Marr <sp=
an dir=3D"ltr"><<a href=3D"mailto:gregmmarr@gmail.com" target=3D"_blank"=
>gregmmarr@gmail.com</a>></span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"im"><span sty=
le=3D"font-size:13px">On Tuesday, October 8, 2013 4:04:23 PM UTC-4, R=E9my =
Lefevre wrote:</span><br>
</div><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 class=
=3D"im">Hi,<br><br>I thought about two new algorithms, that could be named =
"count_while" and "count_until". Here are their behavio=
r:<br>
<br></div><div class=3D"im">What do you think about adding these two compon=
ents to the algorithms library ?</div></div></blockquote><div><br></div><di=
v>Should there be both count_while that takes a T to compare to, and count_=
while_if that takes a predicate? =A0That seems like it would fulfill Vlad&#=
39;s desire to have the word _if in there to indicate that it take a predic=
ate?</div>
<div><br></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
=A0<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/bXrQrkBw59c=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D"_blank">std-pr=
oposals+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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--047d7b6251b0699eb004e8552dbc--
.