Topic: Default argument for second parameter of function std::advance


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Fri, 9 Jan 2015 01:06:15 -0800 (PST)
Raw View
------=_Part_38_1250612402.1420794375624
Content-Type: multipart/alternative;
 boundary="----=_Part_39_1620187225.1420794375624"

------=_Part_39_1620187225.1420794375624
Content-Type: text/plain; charset=UTF-8

Today I have been writing some simple assignment for students and there is
a loop in the program that looks like

auto first = a;
auto last = a;

while ( condition )
{
    // calls of some standard algorithms

    std::advance( last, 1 );
}

and it seems that the statement with advance looks not very well.

The second argument is redundant because in this program there can not be
any other value except 1. So the statement only confuses readers of the
code. It would be much better to write simply

auto first = a;
auto last = a;

while ( condition )
{
    // calls of some standard algorithms

    std::advance( last );
}

Of course there could be written ++last but std::advance looks more
self-descriptive.

So am going to suggest that the second argument had default argument that
equal to 1.

What do you think about this?

--

---
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_39_1620187225.1420794375624
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Today I have been&nbsp;writing some simple assignment=
 for students and there is a loop in the program that looks like</div><div>=
<br></div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><=
br></div><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; =
// calls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&=
nbsp; std::advance( last, 1 );</div><div>}</div><div><br></div><div>and it =
seems that the statement with advance looks not very well. </div><div><br><=
/div><div>The second argument is redundant because in this program there&nb=
sp;can not be any other value except 1. So the statement&nbsp;only confuses=
 readers of the code. It would be much better to write simply</div><div><br=
></div><div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div=
><br></div><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp=
; // calls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp=
;&nbsp; std::advance( last );</div><div>}</div><div><br></div><div>Of cours=
e there could be written ++last but std::advance looks more self-descriptiv=
e.</div><div><br></div><div>So am going to suggest&nbsp;that the second arg=
ument had default argument that equal to 1.</div><div><br></div><div>What d=
o you think about this?</div></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_39_1620187225.1420794375624--
------=_Part_38_1250612402.1420794375624--

.


Author: Miro Knejp <miro.knejp@gmail.com>
Date: Fri, 9 Jan 2015 13:32:53 +0100
Raw View
--Apple-Mail=_B38A2EA5-C041-468D-8962-3D671AFF36F6
Content-Type: text/plain; charset=UTF-8

If you have C++11 there is std::next() and std::prev() that do what you want and use value semantics.

it = std::next(it)
it = std::next(it, 5)

> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad.moscow@mail.ru> wrote:
>
> Today I have been writing some simple assignment for students and there is a loop in the program that looks like
>
> auto first = a;
> auto last = a;
>
> while ( condition )
> {
>     // calls of some standard algorithms
>
>     std::advance( last, 1 );
> }
>
> and it seems that the statement with advance looks not very well.
>
> The second argument is redundant because in this program there can not be any other value except 1. So the statement only confuses readers of the code. It would be much better to write simply
>
> auto first = a;
> auto last = a;
>
> while ( condition )
> {
>     // calls of some standard algorithms
>
>     std::advance( last );
> }
>
> Of course there could be written ++last but std::advance looks more self-descriptive.
>
> So am going to suggest that the second argument had default argument that equal to 1.
>
> What do you think about this?
>
> --
>
> ---
> 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 <mailto:std-proposals+unsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org <mailto:std-proposals@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 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/.

--Apple-Mail=_B38A2EA5-C041-468D-8962-3D671AFF36F6
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dus-ascii"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode=
: space; -webkit-line-break: after-white-space;" class=3D"">If you have C++=
11 there is std::next() and std::prev() that do what you want and use value=
 semantics.<div class=3D""><br class=3D""></div><div class=3D"">it =3D std:=
:next(it)</div><div class=3D"">it =3D std::next(it, 5)</div><div class=3D""=
><br class=3D""><div><blockquote type=3D"cite" class=3D""><div class=3D"">O=
n 09 Jan 2015, at 10:06 , Vlad from Moscow &lt;<a href=3D"mailto:vlad.mosco=
w@mail.ru" class=3D"">vlad.moscow@mail.ru</a>&gt; wrote:</div><br class=3D"=
Apple-interchange-newline"><div class=3D""><div dir=3D"ltr" class=3D""><div=
 class=3D"">Today I have been&nbsp;writing some simple assignment for stude=
nts and there is a loop in the program that looks like</div><div class=3D""=
><br class=3D""></div><div class=3D"">auto first =3D a;<br class=3D""></div=
><div class=3D"">auto last =3D a;</div><div class=3D""><br class=3D""></div=
><div class=3D"">while ( condition )</div><div class=3D"">{</div><div class=
=3D"">&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div cla=
ss=3D""><br class=3D""></div><div class=3D"">&nbsp;&nbsp;&nbsp; std::advanc=
e( last, 1 );</div><div class=3D"">}</div><div class=3D""><br class=3D""></=
div><div class=3D"">and it seems that the statement with advance looks not =
very well. </div><div class=3D""><br class=3D""></div><div class=3D"">The s=
econd argument is redundant because in this program there&nbsp;can not be a=
ny other value except 1. So the statement&nbsp;only confuses readers of the=
 code. It would be much better to write simply</div><div class=3D""><br cla=
ss=3D""></div><div class=3D""><div class=3D"">auto first =3D a;<br class=3D=
""></div><div class=3D"">auto last =3D a;</div><div class=3D""><br class=3D=
""></div><div class=3D"">while ( condition )</div><div class=3D"">{</div><d=
iv class=3D"">&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div>=
<div class=3D""><br class=3D""></div><div class=3D"">&nbsp;&nbsp;&nbsp; std=
::advance( last );</div><div class=3D"">}</div><div class=3D""><br class=3D=
""></div><div class=3D"">Of course there could be written ++last but std::a=
dvance looks more self-descriptive.</div><div class=3D""><br class=3D""></d=
iv><div class=3D"">So am going to suggest&nbsp;that the second argument had=
 default argument that equal to 1.</div><div class=3D""><br class=3D""></di=
v><div class=3D"">What do you think about this?</div></div></div><div class=
=3D""><br class=3D"webkit-block-placeholder"></div>

-- <br class=3D"">
<br class=3D"">
--- <br class=3D"">
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br class=3D"">
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" class=3D"">=
std-proposals+unsubscribe@isocpp.org</a>.<br class=3D"">
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" class=3D"">std-proposals@isocpp.org</a>.<br class=3D"">
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" class=3D"">http://groups.google.com/a/isocpp.org/group/std-=
proposals/</a>.<br class=3D"">
</div></blockquote></div><br class=3D""></div></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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=_B38A2EA5-C041-468D-8962-3D671AFF36F6--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Fri, 9 Jan 2015 04:53:27 -0800 (PST)
Raw View
------=_Part_283_537632966.1420808007357
Content-Type: multipart/alternative;
 boundary="----=_Part_284_1533556633.1420808007358"

------=_Part_284_1533556633.1420808007358
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I know about std;:next and std::prev. But in the code snippet I showed=20
std::next looks even worse.

auto first =3D a;
auto last =3D a;

while ( condition )
{
    // calls of some standard algorithms

   last =3D  std::next( last );
}


What is the sense two times specify last in this code snippet? It looks=20
semantically badly.

And std::next is defined for forward iterators while std;:advance for input=
=20
iterators.

Moreover because std::next and std::prev have the default argument it will=
=20
be logically consistent if std::advance would also have the default=20
argument.


=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=
=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=
=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =D0=BD=D0=B0=D0=BF=D0=B8=D1=
=81=D0=B0=D0=BB:

> If you have C++11 there is std::next() and std::prev() that do what you=
=20
> want and use value semantics.
>
> it =3D std::next(it)
> it =3D std::next(it, 5)
>
> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru=20
> <javascript:>> wrote:
>
> Today I have been writing some simple assignment for students and there i=
s=20
> a loop in the program that looks like
>
> auto first =3D a;
> auto last =3D a;
>
> while ( condition )
> {
>     // calls of some standard algorithms
>
>     std::advance( last, 1 );
> }
>
> and it seems that the statement with advance looks not very well.=20
>
> The second argument is redundant because in this program there can not be=
=20
> any other value except 1. So the statement only confuses readers of the=
=20
> code. It would be much better to write simply
>
> auto first =3D a;
> auto last =3D a;
>
> while ( condition )
> {
>     // calls of some standard algorithms
>
>     std::advance( last );
> }
>
> Of course there could be written ++last but std::advance looks more=20
> self-descriptive.
>
> So am going to suggest that the second argument had default argument that=
=20
> equal to 1.
>
> What do you think about this?
>
> --=20
>
> ---=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to 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_284_1533556633.1420808007358
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I know about std;:next and std::prev. But in the code=
 snippet I showed std::next looks even worse.</div><div><br></div><div>auto=
 first =3D a;<br></div><div>auto last =3D a;</div><div><br></div><div>while=
 ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some st=
andard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp;last =3D &nbsp=
;std::next( last );</div><div>}</div><p><br></p><div>What is the sense two =
times specify last in this code snippet? It looks semantically badly.</div>=
<div><br></div><div>And std::next is defined for forward iterators while st=
d;:advance for input iterators.</div><div><br></div><div>Moreover because s=
td::next and std::prev have the default argument it will be logically consi=
stent if std::advance would also have the default argument.</div><div><br><=
/div><div><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=
=B2=D0=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =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 style=
=3D"-ms-word-wrap: break-word;">If you have C++11 there is std::next() and =
std::prev() that do what you want and use value semantics.<div><br></div><d=
iv>it =3D std::next(it)</div><div>it =3D std::next(it, 5)</div><div><br><di=
v><blockquote type=3D"cite"><div>On 09 Jan 2015, at 10:06 , Vlad from Mosco=
w &lt;<a onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"=
this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"wqKCgD1r4LwJ">vlad....@mail.ru</a>&gt; wrote:<=
/div><br><div><div dir=3D"ltr"><div>Today I have been&nbsp;writing some sim=
ple assignment for students and there is a loop in the program that looks l=
ike</div><div><br></div><div>auto first =3D a;<br></div><div>auto last =3D =
a;</div><div><br></div><div>while ( condition )</div><div>{</div><div>&nbsp=
;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br></div><div=
>&nbsp;&nbsp;&nbsp; std::advance( last, 1 );</div><div>}</div><div><br></di=
v><div>and it seems that the statement with advance looks not very well. </=
div><div><br></div><div>The second argument is redundant because in this pr=
ogram there&nbsp;can not be any other value except 1. So the statement&nbsp=
;only confuses readers of the code. It would be much better to write simply=
</div><div><br></div><div><div>auto first =3D a;<br></div><div>auto last =
=3D a;</div><div><br></div><div>while ( condition )</div><div>{</div><div>&=
nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br></div>=
<div>&nbsp;&nbsp;&nbsp; std::advance( last );</div><div>}</div><div><br></d=
iv><div>Of course there could be written ++last but std::advance looks more=
 self-descriptive.</div><div><br></div><div>So am going to suggest&nbsp;tha=
t the second argument had default argument that equal to 1.</div><div><br><=
/div><div>What do you think about this?</div></div></div><div><br></div>

-- <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 onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"=
_blank" gdf-obfuscated-mailto=3D"wqKCgD1r4LwJ">std-proposal...@<wbr>isocpp.=
org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D'javascr=
ipt:';return true;" onclick=3D"this.href=3D'javascript:';return true;" href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"wqKCgD1r4LwJ">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></blockquote></div><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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_284_1533556633.1420808007358--
------=_Part_283_537632966.1420808007357--

.


Author: TC <rs2740@gmail.com>
Date: Sat, 10 Jan 2015 08:42:14 -0800 (PST)
Raw View
------=_Part_1667_679091470.1420908134917
Content-Type: multipart/alternative;
 boundary="----=_Part_1668_1762236132.1420908134917"

------=_Part_1668_1762236132.1420908134917
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Personally, incrementing an iterator is such a fundamental operation that I=
=20
find ++it to be easier to read (and also shorter) than std::advance(it).=20
YMMV.

std::next(it) and std::prev(it) allows you to express it+1 and  it-1 for=20
non-random-access iterators, so you actually gain something out of it. =20
std::advance(it) is exactly equivalent to ++it, an operator all iterators=
=20
must support, except that it returns void (which most of the times reduces=
=20
its usefulness).



On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote:
>
> I know about std;:next and std::prev. But in the code snippet I showed=20
> std::next looks even worse.
>
> auto first =3D a;
> auto last =3D a;
>
> while ( condition )
> {
>     // calls of some standard algorithms
>
>    last =3D  std::next( last );
> }
>
>
> What is the sense two times specify last in this code snippet? It looks=
=20
> semantically badly.
>
> And std::next is defined for forward iterators while std;:advance for=20
> input iterators.
>
> Moreover because std::next and std::prev have the default argument it wil=
l=20
> be logically consistent if std::advance would also have the default=20
> argument.
>
>
> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=
=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=
=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =D0=BD=D0=B0=D0=BF=D0=B8=D1=
=81=D0=B0=D0=BB:
>
>> If you have C++11 there is std::next() and std::prev() that do what you=
=20
>> want and use value semantics.
>>
>> it =3D std::next(it)
>> it =3D std::next(it, 5)
>>
>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru> wrote:
>>
>> Today I have been writing some simple assignment for students and there=
=20
>> is a loop in the program that looks like
>>
>> auto first =3D a;
>> auto last =3D a;
>>
>> while ( condition )
>> {
>>     // calls of some standard algorithms
>>
>>     std::advance( last, 1 );
>> }
>>
>> and it seems that the statement with advance looks not very well.=20
>>
>> The second argument is redundant because in this program there can not b=
e=20
>> any other value except 1. So the statement only confuses readers of the=
=20
>> code. It would be much better to write simply
>>
>> auto first =3D a;
>> auto last =3D a;
>>
>> while ( condition )
>> {
>>     // calls of some standard algorithms
>>
>>     std::advance( last );
>> }
>>
>> Of course there could be written ++last but std::advance looks more=20
>> self-descriptive.
>>
>> So am going to suggest that the second argument had default argument tha=
t=20
>> equal to 1.
>>
>> What do you think about this?
>>
>> --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org.
>> To post to this group, send email to std-pr...@isocpp.org.
>> 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_1668_1762236132.1420908134917
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Personally, incrementing an iterator is such a fundamental=
 operation that I find <font face=3D"courier new, monospace">++it</font> to=
 be easier to read (and also shorter) than <font face=3D"courier new, monos=
pace">std::advance(it)</font>. YMMV.<div><br></div><div><font face=3D"couri=
er new, monospace">std::next(it)</font> and <font face=3D"courier new, mono=
space">std::prev(it)</font> allows you to express <font face=3D"courier new=
, monospace">it+1</font> and &nbsp;<font face=3D"courier new, monospace">it=
-1</font> for non-random-access iterators, so you actually gain something o=
ut of it. &nbsp;<span style=3D"font-family: 'courier new', monospace; font-=
size: 13.3333330154419px;">std::advance(it)</span><span style=3D"font-size:=
 13.3333330154419px;"><font face=3D"arial, sans-serif"> is exactly equivale=
nt to</font></span><span style=3D"font-size: 13.3333330154419px;"><font fac=
e=3D"arial, sans-serif">&nbsp;</font></span><span style=3D"font-family: 'co=
urier new', monospace; font-size: 13.3333330154419px;">++it,</span><span st=
yle=3D"font-size: 13.3333330154419px;"><font face=3D"arial, sans-serif"> an=
 operator all iterators must support,&nbsp;</font></span><span style=3D"fon=
t-size: 13.3333330154419px;"><font face=3D"arial, sans-serif">except that i=
t returns </font></span><span style=3D"font-family: 'courier new', monospac=
e; font-size: 13.3333330154419px;">void</span><span style=3D"font-size: 13.=
3333330154419px;"><font face=3D"arial, sans-serif"> (which most of the time=
s reduces its usefulness)</font></span><span style=3D"font-family: 'courier=
 new', monospace; font-size: 13.3333330154419px;">.</span></div><div><div><=
br></div><div><br><br>On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad =
from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><div>I know about std;:next and std::prev. But in the code snippet I s=
howed std::next looks even worse.</div><div><br></div><div>auto first =3D a=
;<br></div><div>auto last =3D a;</div><div><br></div><div>while ( condition=
 )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some standard algor=
ithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp;last =3D &nbsp;std::next( =
last );</div><div>}</div><p><br></p><div>What is the sense two times specif=
y last in this code snippet? It looks semantically badly.</div><div><br></d=
iv><div>And std::next is defined for forward iterators while std;:advance f=
or input iterators.</div><div><br></div><div>Moreover because std::next and=
 std::prev have the default argument it will be logically consistent if std=
::advance would also have the default argument.</div><div><br></div><div><b=
r>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=
=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=
=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =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-l=
eft-width:1px;border-left-style:solid"><div>If you have C++11 there is std:=
:next() and std::prev() that do what you want and use value semantics.<div>=
<br></div><div>it =3D std::next(it)</div><div>it =3D std::next(it, 5)</div>=
<div><br><div><blockquote type=3D"cite"><div>On 09 Jan 2015, at 10:06 , Vla=
d from Moscow &lt;<a>vlad....@mail.ru</a>&gt; wrote:</div><br><div><div dir=
=3D"ltr"><div>Today I have been&nbsp;writing some simple assignment for stu=
dents and there is a loop in the program that looks like</div><div><br></di=
v><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br></div=
><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls=
 of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; st=
d::advance( last, 1 );</div><div>}</div><div><br></div><div>and it seems th=
at the statement with advance looks not very well. </div><div><br></div><di=
v>The second argument is redundant because in this program there&nbsp;can n=
ot be any other value except 1. So the statement&nbsp;only confuses readers=
 of the code. It would be much better to write simply</div><div><br></div><=
div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br></d=
iv><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // cal=
ls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; =
std::advance( last );</div><div>}</div><div><br></div><div>Of course there =
could be written ++last but std::advance looks more self-descriptive.</div>=
<div><br></div><div>So am going to suggest&nbsp;that the second argument ha=
d default argument that equal to 1.</div><div><br></div><div>What do you th=
ink about this?</div></div></div><div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>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" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_1668_1762236132.1420908134917--
------=_Part_1667_679091470.1420908134917--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sat, 10 Jan 2015 09:28:42 -0800 (PST)
Raw View
------=_Part_1730_871284071.1420910922999
Content-Type: multipart/alternative;
 boundary="----=_Part_1731_2127876051.1420910922999"

------=_Part_1731_2127876051.1420910922999
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

When the value of expression like ++it is not used in some other=20
expression  or in a control statement of a loop but is used like a separate=
=20
statement as I showed in the example then I wpuld prefer to use=20
std::advance( it );. In fact it is the same as programmers wrote early

( void ) ++it;

You correctly have noted that  std::advance( it ) is equivalent to ++it=20
except  that the last expression has type void. So it shall be indeed=20
equivalent that is the function shall have the default argument for the=20
second parameter.

On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:

> Personally, incrementing an iterator is such a fundamental operation that=
=20
> I find ++it to be easier to read (and also shorter) than std::advance(it)=
..=20
> YMMV.
>
> std::next(it) and std::prev(it) allows you to express it+1 and  it-1 for=
=20
> non-random-access iterators, so you actually gain something out of it. =
=20
> std::advance(it) is exactly equivalent to ++it, an operator all iterators=
=20
> must support, except that it returns void (which most of the times=20
> reduces its usefulness).
>
>
>
> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote:
>>
>> I know about std;:next and std::prev. But in the code snippet I showed=
=20
>> std::next looks even worse.
>>
>> auto first =3D a;
>> auto last =3D a;
>>
>> while ( condition )
>> {
>>     // calls of some standard algorithms
>>
>>    last =3D  std::next( last );
>> }
>>
>>
>> What is the sense two times specify last in this code snippet? It looks=
=20
>> semantically badly.
>>
>> And std::next is defined for forward iterators while std;:advance for=20
>> input iterators.
>>
>> Moreover because std::next and std::prev have the default argument it=20
>> will be logically consistent if std::advance would also have the default=
=20
>> argument.
>>
>>
>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=
=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =D0=BD=D0=B0=D0=BF=D0=B8=
=D1=81=D0=B0=D0=BB:
>>
>>> If you have C++11 there is std::next() and std::prev() that do what you=
=20
>>> want and use value semantics.
>>>
>>> it =3D std::next(it)
>>> it =3D std::next(it, 5)
>>>
>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru> wrote:
>>>
>>> Today I have been writing some simple assignment for students and there=
=20
>>> is a loop in the program that looks like
>>>
>>> auto first =3D a;
>>> auto last =3D a;
>>>
>>> while ( condition )
>>> {
>>>     // calls of some standard algorithms
>>>
>>>     std::advance( last, 1 );
>>> }
>>>
>>> and it seems that the statement with advance looks not very well.=20
>>>
>>> The second argument is redundant because in this program there can not=
=20
>>> be any other value except 1. So the statement only confuses readers of =
the=20
>>> code. It would be much better to write simply
>>>
>>> auto first =3D a;
>>> auto last =3D a;
>>>
>>> while ( condition )
>>> {
>>>     // calls of some standard algorithms
>>>
>>>     std::advance( last );
>>> }
>>>
>>> Of course there could be written ++last but std::advance looks more=20
>>> self-descriptive.
>>>
>>> So am going to suggest that the second argument had default argument=20
>>> that equal to 1.
>>>
>>> What do you think about this?
>>>
>>> --=20
>>>
>>> ---=20
>>> You received this message because you are subscribed to the Google=20
>>> Groups "ISO C++ Standard - Future Proposals" group.
>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>> an email to std-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> 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_1731_2127876051.1420910922999
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>When the value of expression like ++it is not used in=
 some other expression&nbsp;&nbsp;or in a control statement of a loop but i=
s used&nbsp;like a&nbsp;separate statement as I showed in the example then =
I&nbsp;wpuld prefer to use std::advance( it );. In fact it is the&nbsp;same=
 as programmers&nbsp;wrote early</div><div><br></div><div>( void ) ++it;</d=
iv><div><br></div><div>You correctly have noted that &nbsp;std::advance( it=
 ) is equivalent to ++it except&nbsp;&nbsp;that the last expression has typ=
e void. So it shall be indeed equivalent that is the function shall have th=
e default argument for the second parameter.<br><br>On Saturday, January 10=
, 2015 at 7:42:14 PM UTC+3, TC wrote:</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;"><di=
v dir=3D"ltr">Personally, incrementing an iterator is such a fundamental op=
eration that I find <font face=3D"courier new, monospace">++it</font> to be=
 easier to read (and also shorter) than <font face=3D"courier new, monospac=
e">std::advance(it)</font>. YMMV.<div><br></div><div><font face=3D"courier =
new, monospace">std::next(it)</font> and <font face=3D"courier new, monospa=
ce">std::prev(it)</font> allows you to express <font face=3D"courier new, m=
onospace">it+1</font> and &nbsp;<font face=3D"courier new, monospace">it-1<=
/font> for non-random-access iterators, so you actually gain something out =
of it. &nbsp;<span style=3D'font-family: "courier new",monospace; font-size=
: 13.33px;'>std::advance(it)</span><span style=3D"font-size: 13.33px;"><fon=
t face=3D"arial, sans-serif"> is exactly equivalent to</font></span><span s=
tyle=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif">&nbsp;</font>=
</span><span style=3D'font-family: "courier new",monospace; font-size: 13.3=
3px;'>++it,</span><span style=3D"font-size: 13.33px;"><font face=3D"arial, =
sans-serif"> an operator all iterators must support,&nbsp;</font></span><sp=
an style=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif">except th=
at it returns </font></span><span style=3D'font-family: "courier new",monos=
pace; font-size: 13.33px;'>void</span><span style=3D"font-size: 13.33px;"><=
font face=3D"arial, sans-serif"> (which most of the times reduces its usefu=
lness)</font></span><span style=3D'font-family: "courier new",monospace; fo=
nt-size: 13.33px;'>.</span></div><div><div><br></div><div><br><br>On Friday=
, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote:<blockquote c=
lass=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 know about std;:next and std::prev.=
 But in the code snippet I showed std::next looks even worse.</div><div><br=
></div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br>=
</div><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // =
calls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbs=
p;last =3D &nbsp;std::next( last );</div><div>}</div><p><br></p><div>What i=
s the sense two times specify last in this code snippet? It looks semantica=
lly badly.</div><div><br></div><div>And std::next is defined for forward it=
erators while std;:advance for input iterators.</div><div><br></div><div>Mo=
reover because std::next and std::prev have the default argument it will be=
 logically consistent if std::advance would also have the default argument.=
</div><div><br></div><div><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9=
 =D1=8F=D0=BD=D0=B2=D0=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=
=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Kne=
jp =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:</div><blockquote class=3D"gm=
ail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-le=
ft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: so=
lid;"><div>If you have C++11 there is std::next() and std::prev() that do w=
hat you want and use value semantics.<div><br></div><div>it =3D std::next(i=
t)</div><div>it =3D std::next(it, 5)</div><div><br><div><blockquote type=3D=
"cite"><div>On 09 Jan 2015, at 10:06 , Vlad from Moscow &lt;<a>vlad....@mai=
l.ru</a>&gt; wrote:</div><br><div><div dir=3D"ltr"><div>Today I have been&n=
bsp;writing some simple assignment for students and there is a loop in the =
program that looks like</div><div><br></div><div>auto first =3D a;<br></div=
><div>auto last =3D a;</div><div><br></div><div>while ( condition )</div><d=
iv>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div=
><div><br></div><div>&nbsp;&nbsp;&nbsp; std::advance( last, 1 );</div><div>=
}</div><div><br></div><div>and it seems that the statement with advance loo=
ks not very well. </div><div><br></div><div>The second argument is redundan=
t because in this program there&nbsp;can not be any other value except 1. S=
o the statement&nbsp;only confuses readers of the code. It would be much be=
tter to write simply</div><div><br></div><div><div>auto first =3D a;<br></d=
iv><div>auto last =3D a;</div><div><br></div><div>while ( condition )</div>=
<div>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</d=
iv><div><br></div><div>&nbsp;&nbsp;&nbsp; std::advance( last );</div><div>}=
</div><div><br></div><div>Of course there could be written ++last but std::=
advance looks more self-descriptive.</div><div><br></div><div>So am going t=
o suggest&nbsp;that the second argument had default argument that equal to =
1.</div><div><br></div><div>What do you think about this?</div></div></div>=
<div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_1731_2127876051.1420910922999--
------=_Part_1730_871284071.1420910922999--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sat, 10 Jan 2015 09:33:02 -0800 (PST)
Raw View
------=_Part_1898_249846106.1420911182484
Content-Type: multipart/alternative;
 boundary="----=_Part_1899_832973657.1420911182484"

------=_Part_1899_832973657.1420911182484
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I have made a typo in statement
You correctly have noted that  std::advance( it ) is equivalent to ++it=20
except  that the last expression has type void.

There should be "the first expression" instead of "the last expression".:)


On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow wrote:

> When the value of expression like ++it is not used in some other=20
> expression  or in a control statement of a loop but is used like a separa=
te=20
> statement as I showed in the example then I wpuld prefer to use=20
> std::advance( it );. In fact it is the same as programmers wrote early
>
> ( void ) ++it;
>
> You correctly have noted that  std::advance( it ) is equivalent to ++it=
=20
> except  that the last expression has type void. So it shall be indeed=20
> equivalent that is the function shall have the default argument for the=
=20
> second parameter.
>
> On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:
>
>> Personally, incrementing an iterator is such a fundamental operation tha=
t=20
>> I find ++it to be easier to read (and also shorter) than std::advance(it=
).=20
>> YMMV.
>>
>> std::next(it) and std::prev(it) allows you to express it+1 and  it-1 for=
=20
>> non-random-access iterators, so you actually gain something out of it. =
=20
>> std::advance(it) is exactly equivalent to ++it, an operator all=20
>> iterators must support, except that it returns void (which most of the=
=20
>> times reduces its usefulness).
>>
>>
>>
>> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote:
>>>
>>> I know about std;:next and std::prev. But in the code snippet I showed=
=20
>>> std::next looks even worse.
>>>
>>> auto first =3D a;
>>> auto last =3D a;
>>>
>>> while ( condition )
>>> {
>>>     // calls of some standard algorithms
>>>
>>>    last =3D  std::next( last );
>>> }
>>>
>>>
>>> What is the sense two times specify last in this code snippet? It looks=
=20
>>> semantically badly.
>>>
>>> And std::next is defined for forward iterators while std;:advance for=
=20
>>> input iterators.
>>>
>>> Moreover because std::next and std::prev have the default argument it=
=20
>>> will be logically consistent if std::advance would also have the defaul=
t=20
>>> argument.
>>>
>>>
>>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=
=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp=20
>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>
>>>> If you have C++11 there is std::next() and std::prev() that do what yo=
u=20
>>>> want and use value semantics.
>>>>
>>>> it =3D std::next(it)
>>>> it =3D std::next(it, 5)
>>>>
>>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru> wrote:
>>>>
>>>> Today I have been writing some simple assignment for students and ther=
e=20
>>>> is a loop in the program that looks like
>>>>
>>>> auto first =3D a;
>>>> auto last =3D a;
>>>>
>>>> while ( condition )
>>>> {
>>>>     // calls of some standard algorithms
>>>>
>>>>     std::advance( last, 1 );
>>>> }
>>>>
>>>> and it seems that the statement with advance looks not very well.=20
>>>>
>>>> The second argument is redundant because in this program there can not=
=20
>>>> be any other value except 1. So the statement only confuses readers of=
 the=20
>>>> code. It would be much better to write simply
>>>>
>>>> auto first =3D a;
>>>> auto last =3D a;
>>>>
>>>> while ( condition )
>>>> {
>>>>     // calls of some standard algorithms
>>>>
>>>>     std::advance( last );
>>>> }
>>>>
>>>> Of course there could be written ++last but std::advance looks more=20
>>>> self-descriptive.
>>>>
>>>> So am going to suggest that the second argument had default argument=
=20
>>>> that equal to 1.
>>>>
>>>> What do you think about this?
>>>>
>>>> --=20
>>>>
>>>> ---=20
>>>> You received this message because you are subscribed to the Google=20
>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send=
=20
>>>> an email to std-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> 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_1899_832973657.1420911182484
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I have made a typo in statement</div><div>You correct=
ly have noted that &nbsp;std::advance( it ) is equivalent to ++it except&nb=
sp;&nbsp;that the last expression has type void.</div><div><br></div><div>T=
here should be "the&nbsp;first expression" instead of "the last expression"=
..:)</div><div><br><br>On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vl=
ad from Moscow wrote:</div><blockquote class=3D"gmail_quote" style=3D"margi=
n: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 2=
04); border-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><d=
iv>When the value of expression like ++it is not used in some other express=
ion&nbsp;&nbsp;or in a control statement of a loop but is used&nbsp;like a&=
nbsp;separate statement as I showed in the example then I&nbsp;wpuld prefer=
 to use std::advance( it );. In fact it is the&nbsp;same as programmers&nbs=
p;wrote early</div><div><br></div><div>( void ) ++it;</div><div><br></div><=
div>You correctly have noted that &nbsp;std::advance( it ) is equivalent to=
 ++it except&nbsp;&nbsp;that the last expression has type void. So it shall=
 be indeed equivalent that is the function shall have the default argument =
for the second parameter.<br><br>On Saturday, January 10, 2015 at 7:42:14 P=
M UTC+3, TC wrote:</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">Perso=
nally, incrementing an iterator is such a fundamental operation that I find=
 <font face=3D"courier new, monospace">++it</font> to be easier to read (an=
d also shorter) than <font face=3D"courier new, monospace">std::advance(it)=
</font>. YMMV.<div><br></div><div><font face=3D"courier new, monospace">std=
::next(it)</font> and <font face=3D"courier new, monospace">std::prev(it)</=
font> allows you to express <font face=3D"courier new, monospace">it+1</fon=
t> and &nbsp;<font face=3D"courier new, monospace">it-1</font> for non-rand=
om-access iterators, so you actually gain something out of it. &nbsp;<span =
style=3D'font-family: "courier new",monospace; font-size: 13.33px;'>std::ad=
vance(it)</span><span style=3D"font-size: 13.33px;"><font face=3D"arial, sa=
ns-serif"> is exactly equivalent to</font></span><span style=3D"font-size: =
13.33px;"><font face=3D"arial, sans-serif">&nbsp;</font></span><span style=
=3D'font-family: "courier new",monospace; font-size: 13.33px;'>++it,</span>=
<span style=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif"> an op=
erator all iterators must support,&nbsp;</font></span><span style=3D"font-s=
ize: 13.33px;"><font face=3D"arial, sans-serif">except that it returns </fo=
nt></span><span style=3D'font-family: "courier new",monospace; font-size: 1=
3.33px;'>void</span><span style=3D"font-size: 13.33px;"><font face=3D"arial=
, sans-serif"> (which most of the times reduces its usefulness)</font></spa=
n><span style=3D'font-family: "courier new",monospace; font-size: 13.33px;'=
>.</span></div><div><div><br></div><div><br><br>On Friday, January 9, 2015 =
at 7:53:27 AM UTC-5, Vlad from Moscow wrote:<blockquote class=3D"gmail_quot=
e" 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;"><d=
iv dir=3D"ltr"><div>I know about std;:next and std::prev. But in the code s=
nippet I showed std::next looks even worse.</div><div><br></div><div>auto f=
irst =3D a;<br></div><div>auto last =3D a;</div><div><br></div><div>while (=
 condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some stan=
dard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp;last =3D &nbsp;s=
td::next( last );</div><div>}</div><p><br></p><div>What is the sense two ti=
mes specify last in this code snippet? It looks semantically badly.</div><d=
iv><br></div><div>And std::next is defined for forward iterators while std;=
:advance for input iterators.</div><div><br></div><div>Moreover because std=
::next and std::prev have the default argument it will be logically consist=
ent if std::advance would also have the default argument.</div><div><br></d=
iv><div><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=
=B2=D0=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=
=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =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>If yo=
u have C++11 there is std::next() and std::prev() that do what you want and=
 use value semantics.<div><br></div><div>it =3D std::next(it)</div><div>it =
=3D std::next(it, 5)</div><div><br><div><blockquote type=3D"cite"><div>On 0=
9 Jan 2015, at 10:06 , Vlad from Moscow &lt;<a>vlad....@mail.ru</a>&gt; wro=
te:</div><br><div><div dir=3D"ltr"><div>Today I have been&nbsp;writing some=
 simple assignment for students and there is a loop in the program that loo=
ks like</div><div><br></div><div>auto first =3D a;<br></div><div>auto last =
=3D a;</div><div><br></div><div>while ( condition )</div><div>{</div><div>&=
nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br></div>=
<div>&nbsp;&nbsp;&nbsp; std::advance( last, 1 );</div><div>}</div><div><br>=
</div><div>and it seems that the statement with advance looks not very well=
.. </div><div><br></div><div>The second argument is redundant because in thi=
s program there&nbsp;can not be any other value except 1. So the statement&=
nbsp;only confuses readers of the code. It would be much better to write si=
mply</div><div><br></div><div><div>auto first =3D a;<br></div><div>auto las=
t =3D a;</div><div><br></div><div>while ( condition )</div><div>{</div><div=
>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br></di=
v><div>&nbsp;&nbsp;&nbsp; std::advance( last );</div><div>}</div><div><br><=
/div><div>Of course there could be written ++last but std::advance looks mo=
re self-descriptive.</div><div><br></div><div>So am going to suggest&nbsp;t=
hat the second argument had default argument that equal to 1.</div><div><br=
></div><div>What do you think about this?</div></div></div><div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></div></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_1899_832973657.1420911182484--
------=_Part_1898_249846106.1420911182484--

.


Author: "T. C." <rs2740@gmail.com>
Date: Wed, 11 Feb 2015 09:38:52 -0800 (PST)
Raw View
------=_Part_337_917565925.1423676332966
Content-Type: multipart/alternative;
 boundary="----=_Part_338_450432368.1423676332966"

------=_Part_338_450432368.1423676332966
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Just saw the paper. The proposed wording change

// 24.4.4, iterator operations:
template <class InputIterator, class Distance>
void advance(InputIterator& i, Distance n =3D 1);


will not work, since template arguments are not deduced from default=20
function arguments.

If adopted, it will need to be specified either as a pair of overloads, or=
=20
with a default template argument for Distance as well. The former appears=
=20
more conventional.


On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, Vlad from Moscow wrote:
>
> I have made a typo in statement
> You correctly have noted that  std::advance( it ) is equivalent to ++it=
=20
> except  that the last expression has type void.
>
> There should be "the first expression" instead of "the last expression".:=
)
>
>
> On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow wrote=
:
>
>> When the value of expression like ++it is not used in some other=20
>> expression  or in a control statement of a loop but is used like a separ=
ate=20
>> statement as I showed in the example then I wpuld prefer to use=20
>> std::advance( it );. In fact it is the same as programmers wrote early
>>
>> ( void ) ++it;
>>
>> You correctly have noted that  std::advance( it ) is equivalent to ++it=
=20
>> except  that the last expression has type void. So it shall be indeed=20
>> equivalent that is the function shall have the default argument for the=
=20
>> second parameter.
>>
>> On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:
>>
>>> Personally, incrementing an iterator is such a fundamental operation=20
>>> that I find ++it to be easier to read (and also shorter) than=20
>>> std::advance(it). YMMV.
>>>
>>> std::next(it) and std::prev(it) allows you to express it+1 and  it-1=20
>>> for non-random-access iterators, so you actually gain something out of =
it. =20
>>> std::advance(it) is exactly equivalent to ++it, an operator all=20
>>> iterators must support, except that it returns void (which most of the=
=20
>>> times reduces its usefulness).
>>>
>>>
>>>
>>> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote:
>>>>
>>>> I know about std;:next and std::prev. But in the code snippet I showed=
=20
>>>> std::next looks even worse.
>>>>
>>>> auto first =3D a;
>>>> auto last =3D a;
>>>>
>>>> while ( condition )
>>>> {
>>>>     // calls of some standard algorithms
>>>>
>>>>    last =3D  std::next( last );
>>>> }
>>>>
>>>>
>>>> What is the sense two times specify last in this code snippet? It look=
s=20
>>>> semantically badly.
>>>>
>>>> And std::next is defined for forward iterators while std;:advance for=
=20
>>>> input iterators.
>>>>
>>>> Moreover because std::next and std::prev have the default argument it=
=20
>>>> will be logically consistent if std::advance would also have the defau=
lt=20
>>>> argument.
>>>>
>>>>
>>>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=
=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp=20
>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>
>>>>> If you have C++11 there is std::next() and std::prev() that do what=
=20
>>>>> you want and use value semantics.
>>>>>
>>>>> it =3D std::next(it)
>>>>> it =3D std::next(it, 5)
>>>>>
>>>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru> wrote:
>>>>>
>>>>> Today I have been writing some simple assignment for students and=20
>>>>> there is a loop in the program that looks like
>>>>>
>>>>> auto first =3D a;
>>>>> auto last =3D a;
>>>>>
>>>>> while ( condition )
>>>>> {
>>>>>     // calls of some standard algorithms
>>>>>
>>>>>     std::advance( last, 1 );
>>>>> }
>>>>>
>>>>> and it seems that the statement with advance looks not very well.=20
>>>>>
>>>>> The second argument is redundant because in this program there can no=
t=20
>>>>> be any other value except 1. So the statement only confuses readers o=
f the=20
>>>>> code. It would be much better to write simply
>>>>>
>>>>> auto first =3D a;
>>>>> auto last =3D a;
>>>>>
>>>>> while ( condition )
>>>>> {
>>>>>     // calls of some standard algorithms
>>>>>
>>>>>     std::advance( last );
>>>>> }
>>>>>
>>>>> Of course there could be written ++last but std::advance looks more=
=20
>>>>> self-descriptive.
>>>>>
>>>>> So am going to suggest that the second argument had default argument=
=20
>>>>> that equal to 1.
>>>>>
>>>>> What do you think about this?
>>>>>
>>>>> --=20
>>>>>
>>>>> ---=20
>>>>> You received this message because you are subscribed to the Google=20
>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, sen=
d=20
>>>>> an email to std-proposal...@isocpp.org.
>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>> 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_338_450432368.1423676332966
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Just saw the paper. The proposed wording change<div><br></=
div><div><pre style=3D"color: rgb(0, 0, 0);">// 24.4.4, iterator operations=
:
template &lt;class InputIterator, class Distance&gt;
void advance(InputIterator&amp; i, Distance n =3D 1);
</pre><div><br></div><div>will not work, since template arguments are not d=
educed from default function arguments.</div><div><br></div><div>If adopted=
, it will need to be specified either as a pair of overloads, or with a def=
ault template argument for Distance as well. The former appears more conven=
tional.</div><div><br><br>On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, =
Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><div>I have made a typo in statement</div><div>You correctly have=
 noted that &nbsp;std::advance( it ) is equivalent to ++it except&nbsp;&nbs=
p;that the last expression has type void.</div><div><br></div><div>There sh=
ould be "the&nbsp;first expression" instead of "the last expression".:)</di=
v><div><br><br>On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from=
 Moscow wrote:</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);border-lef=
t-width:1px;border-left-style:solid"><div dir=3D"ltr"><div>When the value o=
f expression like ++it is not used in some other expression&nbsp;&nbsp;or i=
n a control statement of a loop but is used&nbsp;like a&nbsp;separate state=
ment as I showed in the example then I&nbsp;wpuld prefer to use std::advanc=
e( it );. In fact it is the&nbsp;same as programmers&nbsp;wrote early</div>=
<div><br></div><div>( void ) ++it;</div><div><br></div><div>You correctly h=
ave noted that &nbsp;std::advance( it ) is equivalent to ++it except&nbsp;&=
nbsp;that the last expression has type void. So it shall be indeed equivale=
nt that is the function shall have the default argument for the second para=
meter.<br><br>On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:<=
/div><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;bor=
der-left-style:solid"><div dir=3D"ltr">Personally, incrementing an iterator=
 is such a fundamental operation that I find <font face=3D"courier new, mon=
ospace">++it</font> to be easier to read (and also shorter) than <font face=
=3D"courier new, monospace">std::advance(it)</font>. YMMV.<div><br></div><d=
iv><font face=3D"courier new, monospace">std::next(it)</font> and <font fac=
e=3D"courier new, monospace">std::prev(it)</font> allows you to express <fo=
nt face=3D"courier new, monospace">it+1</font> and &nbsp;<font face=3D"cour=
ier new, monospace">it-1</font> for non-random-access iterators, so you act=
ually gain something out of it. &nbsp;<span style=3D"font-family:&quot;cour=
ier new&quot;,monospace;font-size:13.33px">std::advance(it)</span><span sty=
le=3D"font-size:13.33px"><font face=3D"arial, sans-serif"> is exactly equiv=
alent to</font></span><span style=3D"font-size:13.33px"><font face=3D"arial=
, sans-serif">&nbsp;</font></span><span style=3D"font-family:&quot;courier =
new&quot;,monospace;font-size:13.33px">++it,</span><span style=3D"font-size=
:13.33px"><font face=3D"arial, sans-serif"> an operator all iterators must =
support,&nbsp;</font></span><span style=3D"font-size:13.33px"><font face=3D=
"arial, sans-serif">except that it returns </font></span><span style=3D"fon=
t-family:&quot;courier new&quot;,monospace;font-size:13.33px">void</span><s=
pan style=3D"font-size:13.33px"><font face=3D"arial, sans-serif"> (which mo=
st of the times reduces its usefulness)</font></span><span style=3D"font-fa=
mily:&quot;courier new&quot;,monospace;font-size:13.33px">.</span></div><di=
v><div><br></div><div><br><br>On Friday, January 9, 2015 at 7:53:27 AM UTC-=
5, Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);bord=
er-left-width:1px;border-left-style:solid"><div dir=3D"ltr"><div>I know abo=
ut std;:next and std::prev. But in the code snippet I showed std::next look=
s even worse.</div><div><br></div><div>auto first =3D a;<br></div><div>auto=
 last =3D a;</div><div><br></div><div>while ( condition )</div><div>{</div>=
<div>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br>=
</div><div>&nbsp;&nbsp;&nbsp;last =3D &nbsp;std::next( last );</div><div>}<=
/div><p><br></p><div>What is the sense two times specify last in this code =
snippet? It looks semantically badly.</div><div><br></div><div>And std::nex=
t is defined for forward iterators while std;:advance for input iterators.<=
/div><div><br></div><div>Moreover because std::next and std::prev have the =
default argument it will be logically consistent if std::advance would also=
 have the default argument.</div><div><br></div><div><br>=D0=BF=D1=8F=D1=82=
=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=80=D1=8F 2015 =D0=
=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=
=D0=B5=D0=BB=D1=8C Miro Knejp =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;pad=
ding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;bord=
er-left-style:solid"><div>If you have C++11 there is std::next() and std::p=
rev() that do what you want and use value semantics.<div><br></div><div>it =
=3D std::next(it)</div><div>it =3D std::next(it, 5)</div><div><br><div><blo=
ckquote type=3D"cite"><div>On 09 Jan 2015, at 10:06 , Vlad from Moscow &lt;=
<a>vlad....@mail.ru</a>&gt; wrote:</div><br><div><div dir=3D"ltr"><div>Toda=
y I have been&nbsp;writing some simple assignment for students and there is=
 a loop in the program that looks like</div><div><br></div><div>auto first =
=3D a;<br></div><div>auto last =3D a;</div><div><br></div><div>while ( cond=
ition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some standard =
algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; std::advance( last, =
1 );</div><div>}</div><div><br></div><div>and it seems that the statement w=
ith advance looks not very well. </div><div><br></div><div>The second argum=
ent is redundant because in this program there&nbsp;can not be any other va=
lue except 1. So the statement&nbsp;only confuses readers of the code. It w=
ould be much better to write simply</div><div><br></div><div><div>auto firs=
t =3D a;<br></div><div>auto last =3D a;</div><div><br></div><div>while ( co=
ndition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls of some standar=
d algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; std::advance( last=
 );</div><div>}</div><div><br></div><div>Of course there could be written +=
+last but std::advance looks more self-descriptive.</div><div><br></div><di=
v>So am going to suggest&nbsp;that the second argument had default argument=
 that equal to 1.</div><div><br></div><div>What do you think about this?</d=
iv></div></div><div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>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" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></div></div></blockquote></div></blockquote></div></blockquote></div></=
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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_338_450432368.1423676332966--
------=_Part_337_917565925.1423676332966--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 11 Feb 2015 10:52:21 -0800 (PST)
Raw View
------=_Part_766_153728345.1423680741141
Content-Type: multipart/alternative;
 boundary="----=_Part_767_289467074.1423680741141"

------=_Part_767_289467074.1423680741141
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

It is my mistake. I will update the proposal.

Thus there are two approaches. Either to declare the function with default=
=20
template argument like this

template <class InputIterator,=20
          class Distance =3D typename=20
std::iterator_traits<InputIterator>::difference_type>
void advance(InputIterator& i, Distance n =3D 1);

Or to declare an overload function like this

template <class InputIterator>,=20
void advance(InputIterator& i)

Do you think that the second approach will be better?



On Wednesday, February 11, 2015 at 8:38:53 PM UTC+3, T. C. wrote:

> Just saw the paper. The proposed wording change
>
> // 24.4.4, iterator operations:
> template <class InputIterator, class Distance>
> void advance(InputIterator& i, Distance n =3D 1);
>
>
> will not work, since template arguments are not deduced from default=20
> function arguments.
>
> If adopted, it will need to be specified either as a pair of overloads, o=
r=20
> with a default template argument for Distance as well. The former appears=
=20
> more conventional.
>
>
> On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, Vlad from Moscow wrote:
>>
>> I have made a typo in statement
>> You correctly have noted that  std::advance( it ) is equivalent to ++it=
=20
>> except  that the last expression has type void.
>>
>> There should be "the first expression" instead of "the last expression".=
:)
>>
>>
>> On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow wrot=
e:
>>
>>> When the value of expression like ++it is not used in some other=20
>>> expression  or in a control statement of a loop but is used like a sepa=
rate=20
>>> statement as I showed in the example then I wpuld prefer to use=20
>>> std::advance( it );. In fact it is the same as programmers wrote early
>>>
>>> ( void ) ++it;
>>>
>>> You correctly have noted that  std::advance( it ) is equivalent to ++it=
=20
>>> except  that the last expression has type void. So it shall be indeed=
=20
>>> equivalent that is the function shall have the default argument for the=
=20
>>> second parameter.
>>>
>>> On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:
>>>
>>>> Personally, incrementing an iterator is such a fundamental operation=
=20
>>>> that I find ++it to be easier to read (and also shorter) than=20
>>>> std::advance(it). YMMV.
>>>>
>>>> std::next(it) and std::prev(it) allows you to express it+1 and  it-1=
=20
>>>> for non-random-access iterators, so you actually gain something out of=
 it. =20
>>>> std::advance(it) is exactly equivalent to ++it, an operator all=20
>>>> iterators must support, except that it returns void (which most of the=
=20
>>>> times reduces its usefulness).
>>>>
>>>>
>>>>
>>>> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote=
:
>>>>>
>>>>> I know about std;:next and std::prev. But in the code snippet I showe=
d=20
>>>>> std::next looks even worse.
>>>>>
>>>>> auto first =3D a;
>>>>> auto last =3D a;
>>>>>
>>>>> while ( condition )
>>>>> {
>>>>>     // calls of some standard algorithms
>>>>>
>>>>>    last =3D  std::next( last );
>>>>> }
>>>>>
>>>>>
>>>>> What is the sense two times specify last in this code snippet? It=20
>>>>> looks semantically badly.
>>>>>
>>>>> And std::next is defined for forward iterators while std;:advance for=
=20
>>>>> input iterators.
>>>>>
>>>>> Moreover because std::next and std::prev have the default argument it=
=20
>>>>> will be logically consistent if std::advance would also have the defa=
ult=20
>>>>> argument.
>>>>>
>>>>>
>>>>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=
=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp=20
>>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>
>>>>>> If you have C++11 there is std::next() and std::prev() that do what=
=20
>>>>>> you want and use value semantics.
>>>>>>
>>>>>> it =3D std::next(it)
>>>>>> it =3D std::next(it, 5)
>>>>>>
>>>>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru> wrote=
:
>>>>>>
>>>>>> Today I have been writing some simple assignment for students and=20
>>>>>> there is a loop in the program that looks like
>>>>>>
>>>>>> auto first =3D a;
>>>>>> auto last =3D a;
>>>>>>
>>>>>> while ( condition )
>>>>>> {
>>>>>>     // calls of some standard algorithms
>>>>>>
>>>>>>     std::advance( last, 1 );
>>>>>> }
>>>>>>
>>>>>> and it seems that the statement with advance looks not very well.=20
>>>>>>
>>>>>> The second argument is redundant because in this program there can=
=20
>>>>>> not be any other value except 1. So the statement only confuses read=
ers of=20
>>>>>> the code. It would be much better to write simply
>>>>>>
>>>>>> auto first =3D a;
>>>>>> auto last =3D a;
>>>>>>
>>>>>> while ( condition )
>>>>>> {
>>>>>>     // calls of some standard algorithms
>>>>>>
>>>>>>     std::advance( last );
>>>>>> }
>>>>>>
>>>>>> Of course there could be written ++last but std::advance looks more=
=20
>>>>>> self-descriptive.
>>>>>>
>>>>>> So am going to suggest that the second argument had default argument=
=20
>>>>>> that equal to 1.
>>>>>>
>>>>>> What do you think about this?
>>>>>>
>>>>>> --=20
>>>>>>
>>>>>> ---=20
>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,=20
>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>> 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_767_289467074.1423680741141
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>It is my mistake. I will update the proposal.</div><d=
iv><br></div><div>Thus there are two approaches. Either to declare the func=
tion with default template argument like this</div><div><br></div><div>temp=
late &lt;class InputIterator, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; class Distance =3D typename std::iterator_traits&lt;InputIter=
ator&gt;::difference_type&gt;<br>void advance(InputIterator&amp; i, Distanc=
e n =3D 1);</div><div><br></div><div>Or to declare an overload function lik=
e this</div><div><br></div><div>template &lt;class InputIterator&gt;, <br>v=
oid advance(InputIterator&amp; i)</div><div><br></div><div>Do you think tha=
t the second approach will be better?<br><br><br><br>On Wednesday, February=
 11, 2015 at 8:38:53 PM UTC+3, T. C. wrote:</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">Just saw the paper. The proposed wording change<div><br=
></div><div><pre style=3D"color: rgb(0, 0, 0);">// 24.4.4, iterator operati=
ons:
template &lt;class InputIterator, class Distance&gt;
void advance(InputIterator&amp; i, Distance n =3D 1);
</pre><div><br></div><div>will not work, since template arguments are not d=
educed from default function arguments.</div><div><br></div><div>If adopted=
, it will need to be specified either as a pair of overloads, or with a def=
ault template argument for Distance as well. The former appears more conven=
tional.</div><div><br><br>On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, =
Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 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=
 have made a typo in statement</div><div>You correctly have noted that &nbs=
p;std::advance( it ) is equivalent to ++it except&nbsp;&nbsp;that the last =
expression has type void.</div><div><br></div><div>There should be "the&nbs=
p;first expression" instead of "the last expression".:)</div><div><br><br>O=
n Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow wrote:</=
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>When the value of ex=
pression like ++it is not used in some other expression&nbsp;&nbsp;or in a =
control statement of a loop but is used&nbsp;like a&nbsp;separate statement=
 as I showed in the example then I&nbsp;wpuld prefer to use std::advance( i=
t );. In fact it is the&nbsp;same as programmers&nbsp;wrote early</div><div=
><br></div><div>( void ) ++it;</div><div><br></div><div>You correctly have =
noted that &nbsp;std::advance( it ) is equivalent to ++it except&nbsp;&nbsp=
;that the last expression has type void. So it shall be indeed equivalent t=
hat is the function shall have the default argument for the second paramete=
r.<br><br>On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:</div=
><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padd=
ing-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1p=
x; border-left-style: solid;"><div dir=3D"ltr">Personally, incrementing an =
iterator is such a fundamental operation that I find <font face=3D"courier =
new, monospace">++it</font> to be easier to read (and also shorter) than <f=
ont face=3D"courier new, monospace">std::advance(it)</font>. YMMV.<div><br>=
</div><div><font face=3D"courier new, monospace">std::next(it)</font> and <=
font face=3D"courier new, monospace">std::prev(it)</font> allows you to exp=
ress <font face=3D"courier new, monospace">it+1</font> and &nbsp;<font face=
=3D"courier new, monospace">it-1</font> for non-random-access iterators, so=
 you actually gain something out of it. &nbsp;<span style=3D'font-family: "=
courier new",monospace; font-size: 13.33px;'>std::advance(it)</span><span s=
tyle=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif"> is exactly e=
quivalent to</font></span><span style=3D"font-size: 13.33px;"><font face=3D=
"arial, sans-serif">&nbsp;</font></span><span style=3D'font-family: "courie=
r new",monospace; font-size: 13.33px;'>++it,</span><span style=3D"font-size=
: 13.33px;"><font face=3D"arial, sans-serif"> an operator all iterators mus=
t support,&nbsp;</font></span><span style=3D"font-size: 13.33px;"><font fac=
e=3D"arial, sans-serif">except that it returns </font></span><span style=3D=
'font-family: "courier new",monospace; font-size: 13.33px;'>void</span><spa=
n style=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif"> (which mo=
st of the times reduces its usefulness)</font></span><span style=3D'font-fa=
mily: "courier new",monospace; font-size: 13.33px;'>.</span></div><div><div=
><br></div><div><br><br>On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vla=
d from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px =
0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bo=
rder-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>I kn=
ow about std;:next and std::prev. But in the code snippet I showed std::nex=
t looks even worse.</div><div><br></div><div>auto first =3D a;<br></div><di=
v>auto last =3D a;</div><div><br></div><div>while ( condition )</div><div>{=
</div><div>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><di=
v><br></div><div>&nbsp;&nbsp;&nbsp;last =3D &nbsp;std::next( last );</div><=
div>}</div><p><br></p><div>What is the sense two times specify last in this=
 code snippet? It looks semantically badly.</div><div><br></div><div>And st=
d::next is defined for forward iterators while std;:advance for input itera=
tors.</div><div><br></div><div>Moreover because std::next and std::prev hav=
e the default argument it will be logically consistent if std::advance woul=
d also have the default argument.</div><div><br></div><div><br>=D0=BF=D1=8F=
=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=80=D1=8F 2015=
 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =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>If you have C++11 there is std:=
:next() and std::prev() that do what you want and use value semantics.<div>=
<br></div><div>it =3D std::next(it)</div><div>it =3D std::next(it, 5)</div>=
<div><br><div><blockquote type=3D"cite"><div>On 09 Jan 2015, at 10:06 , Vla=
d from Moscow &lt;<a>vlad....@mail.ru</a>&gt; wrote:</div><br><div><div dir=
=3D"ltr"><div>Today I have been&nbsp;writing some simple assignment for stu=
dents and there is a loop in the program that looks like</div><div><br></di=
v><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br></div=
><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls=
 of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; st=
d::advance( last, 1 );</div><div>}</div><div><br></div><div>and it seems th=
at the statement with advance looks not very well. </div><div><br></div><di=
v>The second argument is redundant because in this program there&nbsp;can n=
ot be any other value except 1. So the statement&nbsp;only confuses readers=
 of the code. It would be much better to write simply</div><div><br></div><=
div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br></d=
iv><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // cal=
ls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; =
std::advance( last );</div><div>}</div><div><br></div><div>Of course there =
could be written ++last but std::advance looks more self-descriptive.</div>=
<div><br></div><div>So am going to suggest&nbsp;that the second argument ha=
d default argument that equal to 1.</div><div><br></div><div>What do you th=
ink about this?</div></div></div><div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank" rel=3D"nofollow">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></div></div></blockquote></div></blockquote></div></blockquote></div></=
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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_767_289467074.1423680741141--
------=_Part_766_153728345.1423680741141--

.


Author: "T. C." <rs2740@gmail.com>
Date: Wed, 11 Feb 2015 11:35:17 -0800 (PST)
Raw View
------=_Part_774_1630374304.1423683317092
Content-Type: multipart/alternative;
 boundary="----=_Part_775_1957075255.1423683317093"

------=_Part_775_1957075255.1423683317093
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

It's more consistent with the rest of the library. Though that probably has=
=20
something to do with the fact that default template arguments for function=
=20
templates didn't exist in C++03.

On Thursday, February 12, 2015 at 2:52:21 AM UTC+8, Vlad from Moscow wrote:
>
> It is my mistake. I will update the proposal.
>
> Thus there are two approaches. Either to declare the function with defaul=
t=20
> template argument like this
>
> template <class InputIterator,=20
>           class Distance =3D typename=20
> std::iterator_traits<InputIterator>::difference_type>
> void advance(InputIterator& i, Distance n =3D 1);
>
> Or to declare an overload function like this
>
> template <class InputIterator>,=20
> void advance(InputIterator& i)
>
> Do you think that the second approach will be better?
>
>
>
> On Wednesday, February 11, 2015 at 8:38:53 PM UTC+3, T. C. wrote:
>
>> Just saw the paper. The proposed wording change
>>
>> // 24.4.4, iterator operations:
>> template <class InputIterator, class Distance>
>> void advance(InputIterator& i, Distance n =3D 1);
>>
>>
>> will not work, since template arguments are not deduced from default=20
>> function arguments.
>>
>> If adopted, it will need to be specified either as a pair of overloads,=
=20
>> or with a default template argument for Distance as well. The former=20
>> appears more conventional.
>>
>>
>> On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, Vlad from Moscow wrote:
>>>
>>> I have made a typo in statement
>>> You correctly have noted that  std::advance( it ) is equivalent to ++it=
=20
>>> except  that the last expression has type void.
>>>
>>> There should be "the first expression" instead of "the last=20
>>> expression".:)
>>>
>>>
>>> On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow=20
>>> wrote:
>>>
>>>> When the value of expression like ++it is not used in some other=20
>>>> expression  or in a control statement of a loop but is used like a sep=
arate=20
>>>> statement as I showed in the example then I wpuld prefer to use=20
>>>> std::advance( it );. In fact it is the same as programmers wrote early
>>>>
>>>> ( void ) ++it;
>>>>
>>>> You correctly have noted that  std::advance( it ) is equivalent to ++i=
t=20
>>>> except  that the last expression has type void. So it shall be indeed=
=20
>>>> equivalent that is the function shall have the default argument for th=
e=20
>>>> second parameter.
>>>>
>>>> On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:
>>>>
>>>>> Personally, incrementing an iterator is such a fundamental operation=
=20
>>>>> that I find ++it to be easier to read (and also shorter) than=20
>>>>> std::advance(it). YMMV.
>>>>>
>>>>> std::next(it) and std::prev(it) allows you to express it+1 and  it-1=
=20
>>>>> for non-random-access iterators, so you actually gain something out o=
f it. =20
>>>>> std::advance(it) is exactly equivalent to ++it, an operator all=20
>>>>> iterators must support, except that it returns void (which most of=20
>>>>> the times reduces its usefulness).
>>>>>
>>>>>
>>>>>
>>>>> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrot=
e:
>>>>>>
>>>>>> I know about std;:next and std::prev. But in the code snippet I=20
>>>>>> showed std::next looks even worse.
>>>>>>
>>>>>> auto first =3D a;
>>>>>> auto last =3D a;
>>>>>>
>>>>>> while ( condition )
>>>>>> {
>>>>>>     // calls of some standard algorithms
>>>>>>
>>>>>>    last =3D  std::next( last );
>>>>>> }
>>>>>>
>>>>>>
>>>>>> What is the sense two times specify last in this code snippet? It=20
>>>>>> looks semantically badly.
>>>>>>
>>>>>> And std::next is defined for forward iterators while std;:advance fo=
r=20
>>>>>> input iterators.
>>>>>>
>>>>>> Moreover because std::next and std::prev have the default argument i=
t=20
>>>>>> will be logically consistent if std::advance would also have the def=
ault=20
>>>>>> argument.
>>>>>>
>>>>>>
>>>>>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=
=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp=20
>>>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>>
>>>>>>> If you have C++11 there is std::next() and std::prev() that do what=
=20
>>>>>>> you want and use value semantics.
>>>>>>>
>>>>>>> it =3D std::next(it)
>>>>>>> it =3D std::next(it, 5)
>>>>>>>
>>>>>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru>=20
>>>>>>> wrote:
>>>>>>>
>>>>>>> Today I have been writing some simple assignment for students and=
=20
>>>>>>> there is a loop in the program that looks like
>>>>>>>
>>>>>>> auto first =3D a;
>>>>>>> auto last =3D a;
>>>>>>>
>>>>>>> while ( condition )
>>>>>>> {
>>>>>>>     // calls of some standard algorithms
>>>>>>>
>>>>>>>     std::advance( last, 1 );
>>>>>>> }
>>>>>>>
>>>>>>> and it seems that the statement with advance looks not very well.=
=20
>>>>>>>
>>>>>>> The second argument is redundant because in this program there can=
=20
>>>>>>> not be any other value except 1. So the statement only confuses rea=
ders of=20
>>>>>>> the code. It would be much better to write simply
>>>>>>>
>>>>>>> auto first =3D a;
>>>>>>> auto last =3D a;
>>>>>>>
>>>>>>> while ( condition )
>>>>>>> {
>>>>>>>     // calls of some standard algorithms
>>>>>>>
>>>>>>>     std::advance( last );
>>>>>>> }
>>>>>>>
>>>>>>> Of course there could be written ++last but std::advance looks more=
=20
>>>>>>> self-descriptive.
>>>>>>>
>>>>>>> So am going to suggest that the second argument had default argumen=
t=20
>>>>>>> that equal to 1.
>>>>>>>
>>>>>>> What do you think about this?
>>>>>>>
>>>>>>> --=20
>>>>>>>
>>>>>>> ---=20
>>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,=
=20
>>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>>> 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_775_1957075255.1423683317093
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">It's more consistent with the rest of the library. Though =
that probably has something to do with the fact that default template argum=
ents for function templates didn't exist in C++03.<div><br>On Thursday, Feb=
ruary 12, 2015 at 2:52:21 AM UTC+8, Vlad from Moscow wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>It is my mistake. I will=
 update the proposal.</div><div><br></div><div>Thus there are two approache=
s. Either to declare the function with default template argument like this<=
/div><div><br></div><div>template &lt;class InputIterator, <br>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class Distance =3D typename std:=
:iterator_traits&lt;<wbr>InputIterator&gt;::difference_<wbr>type&gt;<br>voi=
d advance(InputIterator&amp; i, Distance n =3D 1);</div><div><br></div><div=
>Or to declare an overload function like this</div><div><br></div><div>temp=
late &lt;class InputIterator&gt;, <br>void advance(InputIterator&amp; i)</d=
iv><div><br></div><div>Do you think that the second approach will be better=
?<br><br><br><br>On Wednesday, February 11, 2015 at 8:38:53 PM UTC+3, T. C.=
 wrote:</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">Just saw the paper. The prop=
osed wording change<div><br></div><div><pre style=3D"color:rgb(0,0,0)">// 2=
4.4.4, iterator operations:
template &lt;class InputIterator, class Distance&gt;
void advance(InputIterator&amp; i, Distance n =3D 1);
</pre><div><br></div><div>will not work, since template arguments are not d=
educed from default function arguments.</div><div><br></div><div>If adopted=
, it will need to be specified either as a pair of overloads, or with a def=
ault template argument for Distance as well. The former appears more conven=
tional.</div><div><br><br>On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, =
Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 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 have made a=
 typo in statement</div><div>You correctly have noted that &nbsp;std::advan=
ce( it ) is equivalent to ++it except&nbsp;&nbsp;that the last expression h=
as type void.</div><div><br></div><div>There should be "the&nbsp;first expr=
ession" instead of "the last expression".:)</div><div><br><br>On Saturday, =
January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow wrote:</div><blockqu=
ote 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-left-styl=
e:solid"><div dir=3D"ltr"><div>When the value of expression like ++it is no=
t used in some other expression&nbsp;&nbsp;or in a control statement of a l=
oop but is used&nbsp;like a&nbsp;separate statement as I showed in the exam=
ple then I&nbsp;wpuld prefer to use std::advance( it );. In fact it is the&=
nbsp;same as programmers&nbsp;wrote early</div><div><br></div><div>( void )=
 ++it;</div><div><br></div><div>You correctly have noted that &nbsp;std::ad=
vance( it ) is equivalent to ++it except&nbsp;&nbsp;that the last expressio=
n has type void. So it shall be indeed equivalent that is the function shal=
l have the default argument for the second parameter.<br><br>On Saturday, J=
anuary 10, 2015 at 7:42:14 PM UTC+3, TC wrote:</div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-c=
olor:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div d=
ir=3D"ltr">Personally, incrementing an iterator is such a fundamental opera=
tion that I find <font face=3D"courier new, monospace">++it</font> to be ea=
sier to read (and also shorter) than <font face=3D"courier new, monospace">=
std::advance(it)</font>. YMMV.<div><br></div><div><font face=3D"courier new=
, monospace">std::next(it)</font> and <font face=3D"courier new, monospace"=
>std::prev(it)</font> allows you to express <font face=3D"courier new, mono=
space">it+1</font> and &nbsp;<font face=3D"courier new, monospace">it-1</fo=
nt> for non-random-access iterators, so you actually gain something out of =
it. &nbsp;<span style=3D"font-family:&quot;courier new&quot;,monospace;font=
-size:13.33px">std::advance(it)</span><span style=3D"font-size:13.33px"><fo=
nt face=3D"arial, sans-serif"> is exactly equivalent to</font></span><span =
style=3D"font-size:13.33px"><font face=3D"arial, sans-serif">&nbsp;</font><=
/span><span style=3D"font-family:&quot;courier new&quot;,monospace;font-siz=
e:13.33px">++it,</span><span style=3D"font-size:13.33px"><font face=3D"aria=
l, sans-serif"> an operator all iterators must support,&nbsp;</font></span>=
<span style=3D"font-size:13.33px"><font face=3D"arial, sans-serif">except t=
hat it returns </font></span><span style=3D"font-family:&quot;courier new&q=
uot;,monospace;font-size:13.33px">void</span><span style=3D"font-size:13.33=
px"><font face=3D"arial, sans-serif"> (which most of the times reduces its =
usefulness)</font></span><span style=3D"font-family:&quot;courier new&quot;=
,monospace;font-size:13.33px">.</span></div><div><div><br></div><div><br><b=
r>On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow wrote:<b=
lockquote 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;border-lef=
t-style:solid"><div dir=3D"ltr"><div>I know about std;:next and std::prev. =
But in the code snippet I showed std::next looks even worse.</div><div><br>=
</div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br><=
/div><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // c=
alls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp=
;last =3D &nbsp;std::next( last );</div><div>}</div><p><br></p><div>What is=
 the sense two times specify last in this code snippet? It looks semantical=
ly badly.</div><div><br></div><div>And std::next is defined for forward ite=
rators while std;:advance for input iterators.</div><div><br></div><div>Mor=
eover because std::next and std::prev have the default argument it will be =
logically consistent if std::advance would also have the default argument.<=
/div><div><br></div><div><br>=D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =
=D1=8F=D0=BD=D0=B2=D0=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=
=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =
=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-colo=
r:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div>If y=
ou have C++11 there is std::next() and std::prev() that do what you want an=
d use value semantics.<div><br></div><div>it =3D std::next(it)</div><div>it=
 =3D std::next(it, 5)</div><div><br><div><blockquote type=3D"cite"><div>On =
09 Jan 2015, at 10:06 , Vlad from Moscow &lt;<a>vlad....@mail.ru</a>&gt; wr=
ote:</div><br><div><div dir=3D"ltr"><div>Today I have been&nbsp;writing som=
e simple assignment for students and there is a loop in the program that lo=
oks like</div><div><br></div><div>auto first =3D a;<br></div><div>auto last=
 =3D a;</div><div><br></div><div>while ( condition )</div><div>{</div><div>=
&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br></div=
><div>&nbsp;&nbsp;&nbsp; std::advance( last, 1 );</div><div>}</div><div><br=
></div><div>and it seems that the statement with advance looks not very wel=
l. </div><div><br></div><div>The second argument is redundant because in th=
is program there&nbsp;can not be any other value except 1. So the statement=
&nbsp;only confuses readers of the code. It would be much better to write s=
imply</div><div><br></div><div><div>auto first =3D a;<br></div><div>auto la=
st =3D a;</div><div><br></div><div>while ( condition )</div><div>{</div><di=
v>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><div><br></d=
iv><div>&nbsp;&nbsp;&nbsp; std::advance( last );</div><div>}</div><div><br>=
</div><div>Of course there could be written ++last but std::advance looks m=
ore self-descriptive.</div><div><br></div><div>So am going to suggest&nbsp;=
that the second argument had default argument that equal to 1.</div><div><b=
r></div><div>What do you think about this?</div></div></div><div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></div></div></blockquote></div></blockquote></div></blockquote></div></=
div></div></blockquote></div></blockquote></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_775_1957075255.1423683317093--
------=_Part_774_1630374304.1423683317092--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 11 Feb 2015 11:44:42 -0800 (PST)
Raw View
------=_Part_822_1993996446.1423683882824
Content-Type: multipart/alternative;
 boundary="----=_Part_823_1615956487.1423683882824"

------=_Part_823_1615956487.1423683882824
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

As for me then I think that the first approach looks more clear and is=20
consistent with declarations of std::next and std::prev.

On Wednesday, February 11, 2015 at 10:35:17 PM UTC+3, T. C. wrote:
>
> It's more consistent with the rest of the library. Though that probably=
=20
> has something to do with the fact that default template arguments for=20
> function templates didn't exist in C++03.
>
> On Thursday, February 12, 2015 at 2:52:21 AM UTC+8, Vlad from Moscow wrot=
e:
>>
>> It is my mistake. I will update the proposal.
>>
>> Thus there are two approaches. Either to declare the function with=20
>> default template argument like this
>>
>> template <class InputIterator,=20
>>           class Distance =3D typename=20
>> std::iterator_traits<InputIterator>::difference_type>
>> void advance(InputIterator& i, Distance n =3D 1);
>>
>> Or to declare an overload function like this
>>
>> template <class InputIterator>,=20
>> void advance(InputIterator& i)
>>
>> Do you think that the second approach will be better?
>>
>>
>>
>> On Wednesday, February 11, 2015 at 8:38:53 PM UTC+3, T. C. wrote:
>>
>>> Just saw the paper. The proposed wording change
>>>
>>> // 24.4.4, iterator operations:
>>> template <class InputIterator, class Distance>
>>> void advance(InputIterator& i, Distance n =3D 1);
>>>
>>>
>>> will not work, since template arguments are not deduced from default=20
>>> function arguments.
>>>
>>> If adopted, it will need to be specified either as a pair of overloads,=
=20
>>> or with a default template argument for Distance as well. The former=20
>>> appears more conventional.
>>>
>>>
>>> On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, Vlad from Moscow wrote=
:
>>>>
>>>> I have made a typo in statement
>>>> You correctly have noted that  std::advance( it ) is equivalent to ++i=
t=20
>>>> except  that the last expression has type void.
>>>>
>>>> There should be "the first expression" instead of "the last=20
>>>> expression".:)
>>>>
>>>>
>>>> On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow=20
>>>> wrote:
>>>>
>>>>> When the value of expression like ++it is not used in some other=20
>>>>> expression  or in a control statement of a loop but is used like a se=
parate=20
>>>>> statement as I showed in the example then I wpuld prefer to use=20
>>>>> std::advance( it );. In fact it is the same as programmers wrote earl=
y
>>>>>
>>>>> ( void ) ++it;
>>>>>
>>>>> You correctly have noted that  std::advance( it ) is equivalent to=20
>>>>> ++it except  that the last expression has type void. So it shall be i=
ndeed=20
>>>>> equivalent that is the function shall have the default argument for t=
he=20
>>>>> second parameter.
>>>>>
>>>>> On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:
>>>>>
>>>>>> Personally, incrementing an iterator is such a fundamental operation=
=20
>>>>>> that I find ++it to be easier to read (and also shorter) than=20
>>>>>> std::advance(it). YMMV.
>>>>>>
>>>>>> std::next(it) and std::prev(it) allows you to express it+1 and  it-1=
=20
>>>>>> for non-random-access iterators, so you actually gain something out =
of it. =20
>>>>>> std::advance(it) is exactly equivalent to ++it, an operator all=20
>>>>>> iterators must support, except that it returns void (which most of=
=20
>>>>>> the times reduces its usefulness).
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow=20
>>>>>> wrote:
>>>>>>>
>>>>>>> I know about std;:next and std::prev. But in the code snippet I=20
>>>>>>> showed std::next looks even worse.
>>>>>>>
>>>>>>> auto first =3D a;
>>>>>>> auto last =3D a;
>>>>>>>
>>>>>>> while ( condition )
>>>>>>> {
>>>>>>>     // calls of some standard algorithms
>>>>>>>
>>>>>>>    last =3D  std::next( last );
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> What is the sense two times specify last in this code snippet? It=
=20
>>>>>>> looks semantically badly.
>>>>>>>
>>>>>>> And std::next is defined for forward iterators while std;:advance=
=20
>>>>>>> for input iterators.
>>>>>>>
>>>>>>> Moreover because std::next and std::prev have the default argument=
=20
>>>>>>> it will be logically consistent if std::advance would also have the=
 default=20
>>>>>>> argument.
>>>>>>>
>>>>>>>
>>>>>>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=
=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=
=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp=20
>>>>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>>>
>>>>>>>> If you have C++11 there is std::next() and std::prev() that do wha=
t=20
>>>>>>>> you want and use value semantics.
>>>>>>>>
>>>>>>>> it =3D std::next(it)
>>>>>>>> it =3D std::next(it, 5)
>>>>>>>>
>>>>>>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru>=20
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Today I have been writing some simple assignment for students and=
=20
>>>>>>>> there is a loop in the program that looks like
>>>>>>>>
>>>>>>>> auto first =3D a;
>>>>>>>> auto last =3D a;
>>>>>>>>
>>>>>>>> while ( condition )
>>>>>>>> {
>>>>>>>>     // calls of some standard algorithms
>>>>>>>>
>>>>>>>>     std::advance( last, 1 );
>>>>>>>> }
>>>>>>>>
>>>>>>>> and it seems that the statement with advance looks not very well.=
=20
>>>>>>>>
>>>>>>>> The second argument is redundant because in this program there can=
=20
>>>>>>>> not be any other value except 1. So the statement only confuses re=
aders of=20
>>>>>>>> the code. It would be much better to write simply
>>>>>>>>
>>>>>>>> auto first =3D a;
>>>>>>>> auto last =3D a;
>>>>>>>>
>>>>>>>> while ( condition )
>>>>>>>> {
>>>>>>>>     // calls of some standard algorithms
>>>>>>>>
>>>>>>>>     std::advance( last );
>>>>>>>> }
>>>>>>>>
>>>>>>>> Of course there could be written ++last but std::advance looks mor=
e=20
>>>>>>>> self-descriptive.
>>>>>>>>
>>>>>>>> So am going to suggest that the second argument had default=20
>>>>>>>> argument that equal to 1.
>>>>>>>>
>>>>>>>> What do you think about this?
>>>>>>>>
>>>>>>>> --=20
>>>>>>>>
>>>>>>>> ---=20
>>>>>>>> You received this message because you are subscribed to the Google=
=20
>>>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,=
=20
>>>>>>>> send an email to std-proposal...@isocpp.org.
>>>>>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>>>>>> 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_823_1615956487.1423683882824
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">As for me then I think that the first approach looks more =
clear and is consistent with declarations of std::next and std::prev.<br><b=
r>On Wednesday, February 11, 2015 at 10:35:17 PM UTC+3, T. C. wrote:<blockq=
uote 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; borde=
r-left-style: solid;"><div dir=3D"ltr">It's more consistent with the rest o=
f the library. Though that probably has something to do with the fact that =
default template arguments for function templates didn't exist in C++03.<di=
v><br>On Thursday, February 12, 2015 at 2:52:21 AM UTC+8, Vlad from Moscow =
wrote:<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"><div>It is my mistake. =
I will update the proposal.</div><div><br></div><div>Thus there are two app=
roaches. Either to declare the function with default template argument like=
 this</div><div><br></div><div>template &lt;class InputIterator, <br>&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; class Distance =3D typenam=
e std::iterator_traits&lt;<wbr>InputIterator&gt;::difference_<wbr>type&gt;<=
br>void advance(InputIterator&amp; i, Distance n =3D 1);</div><div><br></di=
v><div>Or to declare an overload function like this</div><div><br></div><di=
v>template &lt;class InputIterator&gt;, <br>void advance(InputIterator&amp;=
 i)</div><div><br></div><div>Do you think that the second approach will be =
better?<br><br><br><br>On Wednesday, February 11, 2015 at 8:38:53 PM UTC+3,=
 T. C. wrote:</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">Just saw t=
he paper. The proposed wording change<div><br></div><div><pre style=3D"colo=
r: rgb(0, 0, 0);">// 24.4.4, iterator operations:
template &lt;class InputIterator, class Distance&gt;
void advance(InputIterator&amp; i, Distance n =3D 1);
</pre><div><br></div><div>will not work, since template arguments are not d=
educed from default function arguments.</div><div><br></div><div>If adopted=
, it will need to be specified either as a pair of overloads, or with a def=
ault template argument for Distance as well. The former appears more conven=
tional.</div><div><br><br>On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, =
Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 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=
 have made a typo in statement</div><div>You correctly have noted that &nbs=
p;std::advance( it ) is equivalent to ++it except&nbsp;&nbsp;that the last =
expression has type void.</div><div><br></div><div>There should be "the&nbs=
p;first expression" instead of "the last expression".:)</div><div><br><br>O=
n Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow wrote:</=
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>When the value of ex=
pression like ++it is not used in some other expression&nbsp;&nbsp;or in a =
control statement of a loop but is used&nbsp;like a&nbsp;separate statement=
 as I showed in the example then I&nbsp;wpuld prefer to use std::advance( i=
t );. In fact it is the&nbsp;same as programmers&nbsp;wrote early</div><div=
><br></div><div>( void ) ++it;</div><div><br></div><div>You correctly have =
noted that &nbsp;std::advance( it ) is equivalent to ++it except&nbsp;&nbsp=
;that the last expression has type void. So it shall be indeed equivalent t=
hat is the function shall have the default argument for the second paramete=
r.<br><br>On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:</div=
><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padd=
ing-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1p=
x; border-left-style: solid;"><div dir=3D"ltr">Personally, incrementing an =
iterator is such a fundamental operation that I find <font face=3D"courier =
new, monospace">++it</font> to be easier to read (and also shorter) than <f=
ont face=3D"courier new, monospace">std::advance(it)</font>. YMMV.<div><br>=
</div><div><font face=3D"courier new, monospace">std::next(it)</font> and <=
font face=3D"courier new, monospace">std::prev(it)</font> allows you to exp=
ress <font face=3D"courier new, monospace">it+1</font> and &nbsp;<font face=
=3D"courier new, monospace">it-1</font> for non-random-access iterators, so=
 you actually gain something out of it. &nbsp;<span style=3D'font-family: "=
courier new",monospace; font-size: 13.33px;'>std::advance(it)</span><span s=
tyle=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif"> is exactly e=
quivalent to</font></span><span style=3D"font-size: 13.33px;"><font face=3D=
"arial, sans-serif">&nbsp;</font></span><span style=3D'font-family: "courie=
r new",monospace; font-size: 13.33px;'>++it,</span><span style=3D"font-size=
: 13.33px;"><font face=3D"arial, sans-serif"> an operator all iterators mus=
t support,&nbsp;</font></span><span style=3D"font-size: 13.33px;"><font fac=
e=3D"arial, sans-serif">except that it returns </font></span><span style=3D=
'font-family: "courier new",monospace; font-size: 13.33px;'>void</span><spa=
n style=3D"font-size: 13.33px;"><font face=3D"arial, sans-serif"> (which mo=
st of the times reduces its usefulness)</font></span><span style=3D'font-fa=
mily: "courier new",monospace; font-size: 13.33px;'>.</span></div><div><div=
><br></div><div><br><br>On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vla=
d from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px =
0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); bo=
rder-left-width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div>I kn=
ow about std;:next and std::prev. But in the code snippet I showed std::nex=
t looks even worse.</div><div><br></div><div>auto first =3D a;<br></div><di=
v>auto last =3D a;</div><div><br></div><div>while ( condition )</div><div>{=
</div><div>&nbsp;&nbsp;&nbsp; // calls of some standard algorithms</div><di=
v><br></div><div>&nbsp;&nbsp;&nbsp;last =3D &nbsp;std::next( last );</div><=
div>}</div><p><br></p><div>What is the sense two times specify last in this=
 code snippet? It looks semantically badly.</div><div><br></div><div>And st=
d::next is defined for forward iterators while std;:advance for input itera=
tors.</div><div><br></div><div>Moreover because std::next and std::prev hav=
e the default argument it will be logically consistent if std::advance woul=
d also have the default argument.</div><div><br></div><div><br>=D0=BF=D1=8F=
=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=80=D1=8F 2015=
 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=
=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp =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>If you have C++11 there is std:=
:next() and std::prev() that do what you want and use value semantics.<div>=
<br></div><div>it =3D std::next(it)</div><div>it =3D std::next(it, 5)</div>=
<div><br><div><blockquote type=3D"cite"><div>On 09 Jan 2015, at 10:06 , Vla=
d from Moscow &lt;<a>vlad....@mail.ru</a>&gt; wrote:</div><br><div><div dir=
=3D"ltr"><div>Today I have been&nbsp;writing some simple assignment for stu=
dents and there is a loop in the program that looks like</div><div><br></di=
v><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br></div=
><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // calls=
 of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; st=
d::advance( last, 1 );</div><div>}</div><div><br></div><div>and it seems th=
at the statement with advance looks not very well. </div><div><br></div><di=
v>The second argument is redundant because in this program there&nbsp;can n=
ot be any other value except 1. So the statement&nbsp;only confuses readers=
 of the code. It would be much better to write simply</div><div><br></div><=
div><div>auto first =3D a;<br></div><div>auto last =3D a;</div><div><br></d=
iv><div>while ( condition )</div><div>{</div><div>&nbsp;&nbsp;&nbsp; // cal=
ls of some standard algorithms</div><div><br></div><div>&nbsp;&nbsp;&nbsp; =
std::advance( last );</div><div>}</div><div><br></div><div>Of course there =
could be written ++last but std::advance looks more self-descriptive.</div>=
<div><br></div><div>So am going to suggest&nbsp;that the second argument ha=
d default argument that equal to 1.</div><div><br></div><div>What do you th=
ink about this?</div></div></div><div><br></div>

-- <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>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank" rel=3D"nofollow">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></div></div></blockquote></div></blockquote></div></blockquote></div></=
div></div></blockquote></div></blockquote></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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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_823_1615956487.1423683882824--
------=_Part_822_1993996446.1423683882824--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 11 Feb 2015 14:57:50 -0500
Raw View
--001a11c3c34a0c1ea1050ed56b3b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Definitely match std::next/prev, particularly since it is part of your
rationale/motivation.

On Wed, Feb 11, 2015 at 2:44 PM, Vlad from Moscow <vlad.moscow@mail.ru>
wrote:

> As for me then I think that the first approach looks more clear and is
> consistent with declarations of std::next and std::prev.
>
>
> On Wednesday, February 11, 2015 at 10:35:17 PM UTC+3, T. C. wrote:
>>
>> It's more consistent with the rest of the library. Though that probably
>> has something to do with the fact that default template arguments for
>> function templates didn't exist in C++03.
>>
>> On Thursday, February 12, 2015 at 2:52:21 AM UTC+8, Vlad from Moscow
>> wrote:
>>>
>>> It is my mistake. I will update the proposal.
>>>
>>> Thus there are two approaches. Either to declare the function with
>>> default template argument like this
>>>
>>> template <class InputIterator,
>>>           class Distance =3D typename std::iterator_traits<
>>> InputIterator>::difference_type>
>>> void advance(InputIterator& i, Distance n =3D 1);
>>>
>>> Or to declare an overload function like this
>>>
>>> template <class InputIterator>,
>>> void advance(InputIterator& i)
>>>
>>> Do you think that the second approach will be better?
>>>
>>>
>>>
>>> On Wednesday, February 11, 2015 at 8:38:53 PM UTC+3, T. C. wrote:
>>>
>>>> Just saw the paper. The proposed wording change
>>>>
>>>> // 24.4.4, iterator operations:
>>>> template <class InputIterator, class Distance>
>>>> void advance(InputIterator& i, Distance n =3D 1);
>>>>
>>>>
>>>> will not work, since template arguments are not deduced from default
>>>> function arguments.
>>>>
>>>> If adopted, it will need to be specified either as a pair of overloads=
,
>>>> or with a default template argument for Distance as well. The former
>>>> appears more conventional.
>>>>
>>>>
>>>> On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, Vlad from Moscow wrot=
e:
>>>>>
>>>>> I have made a typo in statement
>>>>> You correctly have noted that  std::advance( it ) is equivalent to
>>>>> ++it except  that the last expression has type void.
>>>>>
>>>>> There should be "the first expression" instead of "the last
>>>>> expression".:)
>>>>>
>>>>>
>>>>> On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow
>>>>> wrote:
>>>>>
>>>>>> When the value of expression like ++it is not used in some other
>>>>>> expression  or in a control statement of a loop but is used like a s=
eparate
>>>>>> statement as I showed in the example then I wpuld prefer to use
>>>>>> std::advance( it );. In fact it is the same as programmers wrote ear=
ly
>>>>>>
>>>>>> ( void ) ++it;
>>>>>>
>>>>>> You correctly have noted that  std::advance( it ) is equivalent to
>>>>>> ++it except  that the last expression has type void. So it shall be =
indeed
>>>>>> equivalent that is the function shall have the default argument for =
the
>>>>>> second parameter.
>>>>>>
>>>>>> On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:
>>>>>>
>>>>>>> Personally, incrementing an iterator is such a fundamental operatio=
n
>>>>>>> that I find ++it to be easier to read (and also shorter) than
>>>>>>> std::advance(it). YMMV.
>>>>>>>
>>>>>>> std::next(it) and std::prev(it) allows you to express it+1 and  it-=
1
>>>>>>> for non-random-access iterators, so you actually gain something out=
 of it.
>>>>>>> std::advance(it) is exactly equivalent to ++it, an operator all
>>>>>>> iterators must support, except that it returns void (which most of
>>>>>>> the times reduces its usefulness).
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad from Moscow
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> I know about std;:next and std::prev. But in the code snippet I
>>>>>>>> showed std::next looks even worse.
>>>>>>>>
>>>>>>>> auto first =3D a;
>>>>>>>> auto last =3D a;
>>>>>>>>
>>>>>>>> while ( condition )
>>>>>>>> {
>>>>>>>>     // calls of some standard algorithms
>>>>>>>>
>>>>>>>>    last =3D  std::next( last );
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> What is the sense two times specify last in this code snippet? It
>>>>>>>> looks semantically badly.
>>>>>>>>
>>>>>>>> And std::next is defined for forward iterators while std;:advance
>>>>>>>> for input iterators.
>>>>>>>>
>>>>>>>> Moreover because std::next and std::prev have the default argument
>>>>>>>> it will be logically consistent if std::advance would also have th=
e default
>>>>>>>> argument.
>>>>>>>>
>>>>>>>>
>>>>>>>> =D0=BF=D1=8F=D1=82=D0=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=
=D0=B0=D1=80=D1=8F 2015 =D0=B3., 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=
=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Miro Knejp
>>>>>>>> =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>>>>>>>>
>>>>>>>>> If you have C++11 there is std::next() and std::prev() that do
>>>>>>>>> what you want and use value semantics.
>>>>>>>>>
>>>>>>>>> it =3D std::next(it)
>>>>>>>>> it =3D std::next(it, 5)
>>>>>>>>>
>>>>>>>>> On 09 Jan 2015, at 10:06 , Vlad from Moscow <vlad....@mail.ru>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Today I have been writing some simple assignment for students and
>>>>>>>>> there is a loop in the program that looks like
>>>>>>>>>
>>>>>>>>> auto first =3D a;
>>>>>>>>> auto last =3D a;
>>>>>>>>>
>>>>>>>>> while ( condition )
>>>>>>>>> {
>>>>>>>>>     // calls of some standard algorithms
>>>>>>>>>
>>>>>>>>>     std::advance( last, 1 );
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> and it seems that the statement with advance looks not very well.
>>>>>>>>>
>>>>>>>>> The second argument is redundant because in this program there ca=
n
>>>>>>>>> not be any other value except 1. So the statement only confuses r=
eaders of
>>>>>>>>> the code. It would be much better to write simply
>>>>>>>>>
>>>>>>>>> auto first =3D a;
>>>>>>>>> auto last =3D a;
>>>>>>>>>
>>>>>>>>> while ( condition )
>>>>>>>>> {
>>>>>>>>>     // calls of some standard algorithms
>>>>>>>>>
>>>>>>>>>     std::advance( last );
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Of course there could be written ++last but std::advance looks
>>>>>>>>> more self-descriptive.
>>>>>>>>>
>>>>>>>>> So am going to suggest that the second argument had default
>>>>>>>>> argument that equal to 1.
>>>>>>>>>
>>>>>>>>> What do you think about this?
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>> You received this message because you are subscribed to the Googl=
e
>>>>>>>>> Groups "ISO C++ Standard - Future Proposals" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>> 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/.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  --
>
> ---
> 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/.

--001a11c3c34a0c1ea1050ed56b3b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Definitely match std::next/prev, particularly since it is =
part of your rationale/motivation.<br></div><div class=3D"gmail_extra"><br>=
<div class=3D"gmail_quote">On Wed, Feb 11, 2015 at 2:44 PM, Vlad from Mosco=
w <span dir=3D"ltr">&lt;<a href=3D"mailto:vlad.moscow@mail.ru" target=3D"_b=
lank">vlad.moscow@mail.ru</a>&gt;</span> wrote:<br><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr">As for me then I think that the first approach look=
s more clear and is consistent with declarations of std::next and std::prev=
..<div><div class=3D"h5"><br><br>On Wednesday, February 11, 2015 at 10:35:17=
 PM UTC+3, T. C. wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 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">It&#39;s more cons=
istent with the rest of the library. Though that probably has something to =
do with the fact that default template arguments for function templates did=
n&#39;t exist in C++03.<div><br>On Thursday, February 12, 2015 at 2:52:21 A=
M UTC+8, Vlad from Moscow wrote:<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>It i=
s my mistake. I will update the proposal.</div><div><br></div><div>Thus the=
re are two approaches. Either to declare the function with default template=
 argument like this</div><div><br></div><div>template &lt;class InputIterat=
or, <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 class Distan=
ce =3D typename std::iterator_traits&lt;<u></u>InputIterator&gt;::differenc=
e_<u></u>type&gt;<br>void advance(InputIterator&amp; i, Distance n =3D 1);<=
/div><div><br></div><div>Or to declare an overload function like this</div>=
<div><br></div><div>template &lt;class InputIterator&gt;, <br>void advance(=
InputIterator&amp; i)</div><div><br></div><div>Do you think that the second=
 approach will be better?<br><br><br><br>On Wednesday, February 11, 2015 at=
 8:38:53 PM UTC+3, T. C. wrote:</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: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">Just=
 saw the paper. The proposed wording change<div><br></div><div><pre style=
=3D"color:rgb(0,0,0)">// 24.4.4, iterator operations:
template &lt;class InputIterator, class Distance&gt;
void advance(InputIterator&amp; i, Distance n =3D 1);
</pre><div><br></div><div>will not work, since template arguments are not d=
educed from default function arguments.</div><div><br></div><div>If adopted=
, it will need to be specified either as a pair of overloads, or with a def=
ault template argument for Distance as well. The former appears more conven=
tional.</div><div><br><br>On Sunday, January 11, 2015 at 1:33:02 AM UTC+8, =
Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 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 have made a=
 typo in statement</div><div>You correctly have noted that =C2=A0std::advan=
ce( it ) is equivalent to ++it except=C2=A0=C2=A0that the last expression h=
as type void.</div><div><br></div><div>There should be &quot;the=C2=A0first=
 expression&quot; instead of &quot;the last expression&quot;.:)</div><div><=
br><br>On Saturday, January 10, 2015 at 8:28:43 PM UTC+3, Vlad from Moscow =
wrote:</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>When the value of expres=
sion like ++it is not used in some other expression=C2=A0=C2=A0or in a cont=
rol statement of a loop but is used=C2=A0like a=C2=A0separate statement as =
I showed in the example then I=C2=A0wpuld prefer to use std::advance( it );=
.. In fact it is the=C2=A0same as programmers=C2=A0wrote early</div><div><br=
></div><div>( void ) ++it;</div><div><br></div><div>You correctly have note=
d that =C2=A0std::advance( it ) is equivalent to ++it except=C2=A0=C2=A0tha=
t the last expression has type void. So it shall be indeed equivalent that =
is the function shall have the default argument for the second parameter.<b=
r><br>On Saturday, January 10, 2015 at 7:42:14 PM UTC+3, TC wrote:</div><bl=
ockquote 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;border-left=
-style:solid"><div dir=3D"ltr">Personally, incrementing an iterator is such=
 a fundamental operation that I find <font face=3D"courier new, monospace">=
++it</font> to be easier to read (and also shorter) than <font face=3D"cour=
ier new, monospace">std::advance(it)</font>. YMMV.<div><br></div><div><font=
 face=3D"courier new, monospace">std::next(it)</font> and <font face=3D"cou=
rier new, monospace">std::prev(it)</font> allows you to express <font face=
=3D"courier new, monospace">it+1</font> and =C2=A0<font face=3D"courier new=
, monospace">it-1</font> for non-random-access iterators, so you actually g=
ain something out of it. =C2=A0<span style=3D"font-family:&quot;courier new=
&quot;,monospace;font-size:13.33px">std::advance(it)</span><span style=3D"f=
ont-size:13.33px"><font face=3D"arial, sans-serif"> is exactly equivalent t=
o</font></span><span style=3D"font-size:13.33px"><font face=3D"arial, sans-=
serif">=C2=A0</font></span><span style=3D"font-family:&quot;courier new&quo=
t;,monospace;font-size:13.33px">++it,</span><span style=3D"font-size:13.33p=
x"><font face=3D"arial, sans-serif"> an operator all iterators must support=
,=C2=A0</font></span><span style=3D"font-size:13.33px"><font face=3D"arial,=
 sans-serif">except that it returns </font></span><span style=3D"font-famil=
y:&quot;courier new&quot;,monospace;font-size:13.33px">void</span><span sty=
le=3D"font-size:13.33px"><font face=3D"arial, sans-serif"> (which most of t=
he times reduces its usefulness)</font></span><span style=3D"font-family:&q=
uot;courier new&quot;,monospace;font-size:13.33px">.</span></div><div><div>=
<br></div><div><br><br>On Friday, January 9, 2015 at 7:53:27 AM UTC-5, Vlad=
 from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 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 know about std;=
:next and std::prev. But in the code snippet I showed std::next looks even =
worse.</div><div><br></div><div>auto first =3D a;<br></div><div>auto last =
=3D a;</div><div><br></div><div>while ( condition )</div><div>{</div><div>=
=C2=A0=C2=A0=C2=A0 // calls of some standard algorithms</div><div><br></div=
><div>=C2=A0=C2=A0=C2=A0last =3D =C2=A0std::next( last );</div><div>}</div>=
<p><br></p><div>What is the sense two times specify last in this code snipp=
et? It looks semantically badly.</div><div><br></div><div>And std::next is =
defined for forward iterators while std;:advance for input iterators.</div>=
<div><br></div><div>Moreover because std::next and std::prev have the defau=
lt argument it will be logically consistent if std::advance would also have=
 the default argument.</div><div><br></div><div><br>=D0=BF=D1=8F=D1=82=D0=
=BD=D0=B8=D1=86=D0=B0, 9 =D1=8F=D0=BD=D0=B2=D0=B0=D1=80=D1=8F 2015 =D0=B3.,=
 15:33:00 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=
=B5=D0=BB=D1=8C Miro Knejp =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;paddin=
g-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-=
left-style:solid"><div>If you have C++11 there is std::next() and std::prev=
() that do what you want and use value semantics.<div><br></div><div>it =3D=
 std::next(it)</div><div>it =3D std::next(it, 5)</div><div><br><div><blockq=
uote type=3D"cite"><div>On 09 Jan 2015, at 10:06 , Vlad from Moscow &lt;<a>=
vlad....@mail.ru</a>&gt; wrote:</div><br><div><div dir=3D"ltr"><div>Today I=
 have been=C2=A0writing some simple assignment for students and there is a =
loop in the program that looks like</div><div><br></div><div>auto first =3D=
 a;<br></div><div>auto last =3D a;</div><div><br></div><div>while ( conditi=
on )</div><div>{</div><div>=C2=A0=C2=A0=C2=A0 // calls of some standard alg=
orithms</div><div><br></div><div>=C2=A0=C2=A0=C2=A0 std::advance( last, 1 )=
;</div><div>}</div><div><br></div><div>and it seems that the statement with=
 advance looks not very well. </div><div><br></div><div>The second argument=
 is redundant because in this program there=C2=A0can not be any other value=
 except 1. So the statement=C2=A0only confuses readers of the code. It woul=
d be much better to write simply</div><div><br></div><div><div>auto first =
=3D a;<br></div><div>auto last =3D a;</div><div><br></div><div>while ( cond=
ition )</div><div>{</div><div>=C2=A0=C2=A0=C2=A0 // calls of some standard =
algorithms</div><div><br></div><div>=C2=A0=C2=A0=C2=A0 std::advance( last )=
;</div><div>}</div><div><br></div><div>Of course there could be written ++l=
ast but std::advance looks more self-descriptive.</div><div><br></div><div>=
So am going to suggest=C2=A0that the second argument had default argument t=
hat equal to 1.</div><div><br></div><div>What do you think about this?</div=
></div></div><div><br></div>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" rel=3D"nofollow" target=3D"_blank">http://groups.google.com=
/a/<u></u>isocpp.org/group/std-<u></u>proposals/</a>.<br>
</div></blockquote></div><br></div></div></blockquote></div></blockquote></=
div></div></div></blockquote></div></blockquote></div></blockquote></div></=
div></div></blockquote></div></blockquote></div></div></blockquote></div></=
div></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
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&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
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 />

--001a11c3c34a0c1ea1050ed56b3b--

.