Topic: Reversed range based for


Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Tue, 27 Aug 2013 11:57:58 -0700 (PDT)
Raw View
------=_Part_405_10366598.1377629878531
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Here is an implementation for reversed for loop that does not need any core=
=20
language changes or range class. As far as I can understand it would also=
=20
work for a future range class template:



template<typename C> struct container_reverser {
container_reverser(C& cont) : container(cont) {}

C& container;
};


template<typename C> typename C::reverse_iterator=20
begin(container_reverser<C>& cont) {
return std::reverse_iterator<typename=20
C::iterator>(std::end(cont.container));
}

template<typename C> typename C::reverse_iterator=20
end(container_reverser<C>& cont) {
return std::reverse_iterator<typename=20
C::iterator>(std::begin(cont.container));
}


template<typename C> container_reverser<C> reversed(C& cont)
{
return container_reverser<C>(cont);
}


This code will have to be complemented with overloads for const and for=20
arrays.

Personally I think that the "modifying function" is a nicer syntax than the=
=20
operator| suggested before in this thread.


Den tisdagen den 6:e november 2012 kl. 22:07:40 UTC+1 skrev Nicol Bolas:
>
>
>
> On Tuesday, November 6, 2012 12:48:19 PM UTC-8, toma...@gmail.com wrote:
>>
>>
>>
>> W dniu wtorek, 6 listopada 2012 21:31:22 UTC+1 u=C5=BCytkownik Vlad from=
=20
>> Moscow napisa=C5=82:
>>>
>>>
>>> =D0=B2=D1=82=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 6 =D0=BD=D0=BE=D1=8F=D0=B1=
=D1=80=D1=8F 2012 =D0=B3., 23:44:46 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=
=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C toma...@gmail.com=D0=BD=D0=B0=D0=BF=
=D0=B8=D1=81=D0=B0=D0=BB:
>>>>
>>>> I already made a proposal to introduce general functions cbegin, cend,=
=20
>>>>> rcbegin, and rcend in the C++ Standard.=20
>>>>> I think it would be logically consistent to introduce also  reversed=
=20
>>>>> range based for statement. Something as=20
>>>>>
>>>>> for ( auto i : reverse v )
>>>>
>>>>
>>>> I think the Boost.Range adapters provides a nice solution (
>>>> http://www.boost.org/doc/libs/1_49_0/libs/range/doc/html/range/referen=
ce/adaptors/reference/reversed.html
>>>> ).
>>>> for (auto i : v | reversed )
>>>>
>>>> The constant adaptor may be added, so the following one will be well=
=20
>>>> formed:
>>>> for (auto i : v | reversed)
>>>> for (auto i : v | constant | reversed)
>>>>
>>> It is not a standard way to perform this. I think that there shall be a=
=20
>>> standard way that is the way adopted in the Standard to record the reve=
rsed=20
>>> range-based for statement. =20
>>>
>> =20
>>  But there is a proposal to incorporate its into the standard=20
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1871.html#range=
-adapters-part-4,=20
>> so maybe 2 new adapters (reversed | constant) should be considered inste=
ad=20
>> of whole new proposal.
>>
>
> That's a rather old proposal. Much better is the fact that there's now an=
=20
> entire study-group devoted *just* to getting ranges, range adapters, and=
=20
> range iterators into the standard.
>

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

<div dir=3D"ltr">Here is an implementation for reversed for loop that does =
not need any core language changes or range class. As far as I can understa=
nd it would also work for a future range class template:<div><br></div><div=
><div><br></div><div><font face=3D"courier new, monospace"><br></font></div=
><div><font face=3D"courier new, monospace">template&lt;typename C&gt; stru=
ct container_reverser {</font></div><div><font face=3D"courier new, monospa=
ce"><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>contai=
ner_reverser(C&amp; cont) : container(cont) {}</font></div><div><font face=
=3D"courier new, monospace"><br></font></div><div><font face=3D"courier new=
, monospace"><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </sp=
an>C&amp; container;</font></div><div><font face=3D"courier new, monospace"=
>};</font></div><div><font face=3D"courier new, monospace"><br></font></div=
><div><font face=3D"courier new, monospace"><br></font></div><div><font fac=
e=3D"courier new, monospace">template&lt;typename C&gt; typename C::reverse=
_iterator begin(container_reverser&lt;C&gt;&amp; cont) {</font></div><div><=
font face=3D"courier new, monospace"><span class=3D"Apple-tab-span" style=
=3D"white-space:pre"> </span>return std::reverse_iterator&lt;typename C::it=
erator&gt;(std::end(cont.container));</font></div><div><font face=3D"courie=
r new, monospace">}</font></div><div><font face=3D"courier new, monospace">=
<br></font></div><div><font face=3D"courier new, monospace">template&lt;typ=
ename C&gt; typename C::reverse_iterator end(container_reverser&lt;C&gt;&am=
p; cont) {</font></div><div><font face=3D"courier new, monospace"><span cla=
ss=3D"Apple-tab-span" style=3D"white-space:pre"> </span>return std::reverse=
_iterator&lt;typename C::iterator&gt;(std::begin(cont.container));</font></=
div><div><font face=3D"courier new, monospace">}</font></div><div><font fac=
e=3D"courier new, monospace"><br></font></div><div><font face=3D"courier ne=
w, monospace"><br></font></div><div><font face=3D"courier new, monospace">t=
emplate&lt;typename C&gt; container_reverser&lt;C&gt; reversed(C&amp; cont)=
</font></div><div><font face=3D"courier new, monospace">{</font></div><div>=
<font face=3D"courier new, monospace"><span class=3D"Apple-tab-span" style=
=3D"white-space:pre"> </span>return container_reverser&lt;C&gt;(cont);</fon=
t></div><div><font face=3D"courier new, monospace">}</font></div><div><br><=
/div><div><br></div><div>This code will have to be complemented with overlo=
ads for const and for arrays.</div><div><br></div><div>Personally I think t=
hat the "modifying function" is a nicer syntax than the operator| suggested=
 before in this thread.</div><div><br></div><br>Den tisdagen den 6:e novemb=
er 2012 kl. 22:07:40 UTC+1 skrev Nicol Bolas:<blockquote class=3D"gmail_quo=
te" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddi=
ng-left: 1ex;"><br><br>On Tuesday, November 6, 2012 12:48:19 PM UTC-8, <a>t=
oma...@gmail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br>=
W dniu wtorek, 6 listopada 2012 21:31:22 UTC+1 u=C5=BCytkownik Vlad from Mo=
scow napisa=C5=82:<blockquote class=3D"gmail_quote" style=3D"margin:0;margi=
n-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><br>=D0=B2=D1=82=
=D0=BE=D1=80=D0=BD=D0=B8=D0=BA, 6 =D0=BD=D0=BE=D1=8F=D0=B1=D1=80=D1=8F 2012=
&nbsp;=D0=B3., 23:44:46 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=
=B0=D1=82=D0=B5=D0=BB=D1=8C <a>toma...@gmail.com</a> =D0=BD=D0=B0=D0=BF=D0=
=B8=D1=81=D0=B0=D0=BB:<blockquote style=3D"margin:0px 0px 0px 0.8ex;padding=
-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-l=
eft-style:solid" class=3D"gmail_quote"><blockquote style=3D"margin:0px 0px =
0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-w=
idth:1px;border-left-style:solid" class=3D"gmail_quote">I already made a pr=
oposal to introduce general functions cbegin, cend,
<br>rcbegin, and rcend in the C++ Standard.
<br>I think it would be logically consistent to introduce also &nbsp;revers=
ed
<br>range based for statement. Something as
<br>
<br>for ( auto i : reverse v )</blockquote><div><br>I think the Boost.Range=
 adapters provides a nice solution (<a href=3D"http://www.boost.org/doc/lib=
s/1_49_0/libs/range/doc/html/range/reference/adaptors/reference/reversed.ht=
ml" target=3D"_blank">http://www.boost.org/doc/<wbr>libs/1_49_0/libs/range/=
doc/<wbr>html/range/reference/adaptors/<wbr>reference/reversed.html</a>).<b=
r>for (auto i : v | reversed )<br><br>The constant adaptor may be added, so=
 the following one will be well formed:<br>for (auto i : v | reversed)<br>f=
or (auto i : v | constant | reversed)<br></div></blockquote><div>It is not =
a standard way to perform this. I think that there&nbsp;shall be a standard=
 way that is the way adopted in the Standard to&nbsp;record&nbsp;the revers=
ed range-based for statement.&nbsp;&nbsp;</div></blockquote><div>&nbsp;</di=
v><div>&nbsp;But there is a proposal to incorporate its into the standard <=
a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1871.htm=
l#range-adapters-part-4" target=3D"_blank">http://www.open-std.org/jtc1/<wb=
r>sc22/wg21/docs/papers/2005/<wbr>n1871.html#range-adapters-<wbr>part-4</a>=
, so maybe 2 new adapters (reversed | constant) should be considered instea=
d of whole new proposal.<br></div></blockquote><div><br>That's a rather old=
 proposal. Much better is the fact that there's now an entire study-group d=
evoted <i>just</i> to getting ranges, range adapters, and range iterators i=
nto the standard.<br></div></blockquote></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_405_10366598.1377629878531--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Tue, 27 Aug 2013 15:49:36 -0400
Raw View
On Tue, Aug 27, 2013 at 2:57 PM, Bengt Gustafsson
<bengt.gustafsson@beamways.com> wrote:
> template<typename C> typename C::reverse_iterator
> begin(container_reverser<C>& cont) {
> return std::reverse_iterator<typename
> C::iterator>(std::end(cont.container));
> }

I'm thinking whether we should standardize make_reverse_iterator
as well.  It's fairly useful when dealing with something like C strings.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 27 Aug 2013 21:53:42 +0200
Raw View
> I'm thinking whether we should standardize make_reverse_iterator
> as well.  It's fairly useful when dealing with something like C strings.

I tend to agree.

-Daniel

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Tue, 27 Aug 2013 22:20:47 +0200
Raw View
Daniel Kr=FCgler skrev 2013-08-27 21:53:
>> I'm thinking whether we should standardize make_reverse_iterator
>> as well.  It's fairly useful when dealing with something like C strings.
> I tend to agree.

Me to, as when I generalized the begin(reverser<C>) to handle classes=20
which don't have a nested type called 'iterator', like regular arrays=20
for instance, I ended up with this, which is not something you want to=20
write too often:

     template<typename C> auto begin(container_reverser<C>&=20
cont)->reverse_iterator<decltype(end(cont.container))> {
         return=20
reverse_iterator<decltype(end(cont.container))>(end(cont.container));
     }

Which could be simplified to:

     template<typename C> auto begin(container_reverser<C>& cont) {
         return make_reverse_iterator(end(cont.container));
     }

given make_reverse_iterator() and the new better 'auto' return type=20
handling for functions, which I don't have in VS2012-Nov 2012 CTP.

--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=F6ping, Sweden
+46 13 465 10 85
www.beamways.com

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: =?UTF-8?Q?R=C3=B3bert_D=C3=A1vid?= <lrdxgm@gmail.com>
Date: Tue, 27 Aug 2013 17:35:28 -0700 (PDT)
Raw View
------=_Part_563_27906659.1377650129103
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Wouldn't ranges have some kind of solution to reverse ranges? If containers=
=20
are convertible to ranges, then the reversed ranged based for would look=20
something like:
for(auto elem : std::ranges::reverse(container)) { ... }

Also shouldn't the "reversed begin" call rbegin(), instead of end()? (And=
=20
end calling rend())

Regards, Robert



2013. augusztus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt Gustafsson a=
=20
k=C3=B6vetkez=C5=91t =C3=ADrta:
>
>
> Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:=20
> >> I'm thinking whether we should standardize make_reverse_iterator=20
> >> as well.  It's fairly useful when dealing with something like C=20
> strings.=20
> > I tend to agree.=20
>
> Me to, as when I generalized the begin(reverser<C>) to handle classes=20
> which don't have a nested type called 'iterator', like regular arrays=20
> for instance, I ended up with this, which is not something you want to=20
> write too often:=20
>
>      template<typename C> auto begin(container_reverser<C>&=20
> cont)->reverse_iterator<decltype(end(cont.container))> {=20
>          return=20
> reverse_iterator<decltype(end(cont.container))>(end(cont.container));=20
>      }=20
>
> Which could be simplified to:=20
>
>      template<typename C> auto begin(container_reverser<C>& cont) {=20
>          return make_reverse_iterator(end(cont.container));=20
>      }=20
>
> given make_reverse_iterator() and the new better 'auto' return type=20
> handling for functions, which I don't have in VS2012-Nov 2012 CTP.=20
>
> --=20
> Bengt Gustafsson=20
> CEO, Beamways AB=20
> Westmansgatan 37A=20
> 582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden=20
> +46 13 465 10 85=20
> www.beamways.com=20
>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_563_27906659.1377650129103
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Wouldn't ranges have some kind of solution to reverse rang=
es? If containers are convertible to ranges, then the reversed ranged based=
 for would look something like:<br><div class=3D"prettyprint" style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">for</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> elem </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">ranges</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">reverse</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">container</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></di=
v><br>Also shouldn't the "reversed begin" call rbegin(), instead of end()? =
(And end calling rend())<br><br>Regards, Robert<br><br><br><br>2013. augusz=
tus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt Gustafsson a k=C3=B6vetk=
ez=C5=91t =C3=ADrta:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<br>Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:
<br>&gt;&gt; I'm thinking whether we should standardize make_reverse_iterat=
or
<br>&gt;&gt; as well. &nbsp;It's fairly useful when dealing with something =
like C strings.
<br>&gt; I tend to agree.
<br>
<br>Me to, as when I generalized the begin(reverser&lt;C&gt;) to handle cla=
sses=20
<br>which don't have a nested type called 'iterator', like regular arrays=
=20
<br>for instance, I ended up with this, which is not something you want to=
=20
<br>write too often:
<br>
<br>&nbsp; &nbsp; &nbsp;template&lt;typename C&gt; auto begin(container_rev=
erser&lt;C&gt;&amp;=20
<br>cont)-&gt;reverse_iterator&lt;<wbr>decltype(end(cont.container))&gt; {
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return=20
<br>reverse_iterator&lt;decltype(end(<wbr>cont.container))&gt;(end(cont.<wb=
r>container));
<br>&nbsp; &nbsp; &nbsp;}
<br>
<br>Which could be simplified to:
<br>
<br>&nbsp; &nbsp; &nbsp;template&lt;typename C&gt; auto begin(container_rev=
erser&lt;C&gt;&amp; cont) {
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return make_reverse_iterator(end(<wbr=
>cont.container));
<br>&nbsp; &nbsp; &nbsp;}
<br>
<br>given make_reverse_iterator() and the new better 'auto' return type=20
<br>handling for functions, which I don't have in VS2012-Nov 2012 CTP.
<br>
<br>--=20
<br>Bengt Gustafsson
<br>CEO, Beamways AB
<br>Westmansgatan 37A
<br>582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden
<br>+46 13 465 10 85
<br><a href=3D"http://www.beamways.com" target=3D"_blank">www.beamways.com<=
/a>
<br>
<br></blockquote></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_563_27906659.1377650129103--

.


Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Wed, 28 Aug 2013 09:54:45 +0200
Raw View
This is a multi-part message in MIME format.
--------------000304050700090100090006
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

I was suggesting that, as ranges seem to be slow in coming, a simple=20
std::reversed() function that works today in all range based for loops=20
could be added. As it works also for ranges (if implemented anything=20
like I suspect) it would not cause duplicating functionality later.

Also, as reversed() is not so closely related to ranges but works more=20
generally I would not want it to be in a special ranges namespace (if=20
there is one).



R=C3=B3bert D=C3=A1vid skrev 2013-08-28 02:35:
> Wouldn't ranges have some kind of solution to reverse ranges? If=20
> containers are convertible to ranges, then the reversed ranged based=20
> for would look something like:
> |
> for(autoelem :std::ranges::reverse(container)){...}
> |
>
> Also shouldn't the "reversed begin" call rbegin(), instead of end()?=20
> (And end calling rend())
>
> Regards, Robert
>
>
>
> 2013. augusztus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt Gustafsson=
 a=20
> k=C3=B6vetkez=C5=91t =C3=ADrta:
>
>
>     Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:
>     >> I'm thinking whether we should standardize make_reverse_iterator
>     >> as well.  It's fairly useful when dealing with something like C
>     strings.
>     > I tend to agree.
>
>     Me to, as when I generalized the begin(reverser<C>) to handle classes
>     which don't have a nested type called 'iterator', like regular arrays
>     for instance, I ended up with this, which is not something you
>     want to
>     write too often:
>
>          template<typename C> auto begin(container_reverser<C>&
>     cont)->reverse_iterator<decltype(end(cont.container))> {
>              return
>     reverse_iterator<decltype(end(cont.container))>(end(cont.container));
>          }
>
>     Which could be simplified to:
>
>          template<typename C> auto begin(container_reverser<C>& cont) {
>              return make_reverse_iterator(end(cont.container));
>          }
>
>     given make_reverse_iterator() and the new better 'auto' return type
>     handling for functions, which I don't have in VS2012-Nov 2012 CTP.
>
>     --=20
>     Bengt Gustafsson
>     CEO, Beamways AB
>     Westmansgatan 37A
>     582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden
>     +46 13 465 10 85
>     www.beamways.com <http://www.beamways.com>
>
> --=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-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at=20
> http://groups.google.com/a/isocpp.org/group/std-proposals/.

--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=C3=B6ping, Sweden
+46 13 465 10 85
www.beamways.com

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an 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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body text=3D"#000000" bgcolor=3D"#FFFFFF">
    I was suggesting that, as ranges seem to be slow in coming, a simple
    std::reversed() function that works today in all range based for
    loops could be added. As it works also for ranges (if implemented
    anything like I suspect) it would not cause duplicating
    functionality later.<br>
    <br>
    Also, as reversed() is not so closely related to ranges but works
    more generally I would not want it to be in a special ranges
    namespace (if there is one).<br>
    <br>
    <br>
    <br>
    <div class=3D"moz-cite-prefix">R=C3=B3bert D=C3=A1vid skrev 2013-08-28 =
02:35:<br>
    </div>
    <blockquote
      cite=3D"mid:c2099870-2379-409d-8bfa-222a2e37447e@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">Wouldn't ranges have some kind of solution to
        reverse ranges? If containers are convertible to ranges, then
        the reversed ranged based for would look something like:<br>
        <div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #008;"
                class=3D"styled-by-prettify">for</span><span style=3D"color=
:
                #660;" class=3D"styled-by-prettify">(</span><span
                style=3D"color: #008;" class=3D"styled-by-prettify">auto</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> elem <=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">:</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">ranges<=
/span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">reverse=
</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">contain=
er</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">))</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">...</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
></div>
          </code></div>
        <br>
        Also shouldn't the "reversed begin" call rbegin(), instead of
        end()? (And end calling rend())<br>
        <br>
        Regards, Robert<br>
        <br>
        <br>
        <br>
        2013. augusztus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt
        Gustafsson a k=C3=B6vetkez=C5=91t =C3=ADrta:
        <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
          0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
          <br>
          Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:
          <br>
          &gt;&gt; I'm thinking whether we should standardize
          make_reverse_iterator
          <br>
          &gt;&gt; as well. =C2=A0It's fairly useful when dealing with
          something like C strings.
          <br>
          &gt; I tend to agree.
          <br>
          <br>
          Me to, as when I generalized the begin(reverser&lt;C&gt;) to
          handle classes <br>
          which don't have a nested type called 'iterator', like regular
          arrays <br>
          for instance, I ended up with this, which is not something you
          want to <br>
          write too often:
          <br>
          <br>
          =C2=A0 =C2=A0 =C2=A0template&lt;typename C&gt; auto
          begin(container_reverser&lt;C&gt;&amp; <br>
          cont)-&gt;reverse_iterator&lt;<wbr>decltype(end(cont.container))&=
gt;
          {
          <br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return <br>
          reverse_iterator&lt;decltype(end(<wbr>cont.container))&gt;(end(co=
nt.<wbr>container));
          <br>
          =C2=A0 =C2=A0 =C2=A0}
          <br>
          <br>
          Which could be simplified to:
          <br>
          <br>
          =C2=A0 =C2=A0 =C2=A0template&lt;typename C&gt; auto
          begin(container_reverser&lt;C&gt;&amp; cont) {
          <br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return make_reverse_iterator(en=
d(<wbr>cont.container));
          <br>
          =C2=A0 =C2=A0 =C2=A0}
          <br>
          <br>
          given make_reverse_iterator() and the new better 'auto' return
          type <br>
          handling for functions, which I don't have in VS2012-Nov 2012
          CTP.
          <br>
          <br>
          -- <br>
          Bengt Gustafsson
          <br>
          CEO, Beamways AB
          <br>
          Westmansgatan 37A
          <br>
          582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden
          <br>
          +46 13 465 10 85
          <br>
          <a moz-do-not-send=3D"true" href=3D"http://www.beamways.com"
            target=3D"_blank">www.beamways.com</a>
          <br>
          <br>
        </blockquote>
      </div>
      -- <br>
      =C2=A0<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 email to <a class=3D"moz-txt-link-abbreviated" href=3D"mailto=
:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org=
</a>.<br>
      To post to this group, send email to <a class=3D"moz-txt-link-abbrevi=
ated" href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>=
..<br>
      Visit this group at <a moz-do-not-send=3D"true"
        href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/"=
>http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br>
    </blockquote>
    <br>
    <pre class=3D"moz-signature" cols=3D"72">--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=C3=B6ping, Sweden
+46 13 465 10 85
<a class=3D"moz-txt-link-abbreviated" href=3D"http://www.beamways.com">www.=
beamways.com</a>
</pre>
  </body>
</html>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--------------000304050700090100090006--

.


Author: Geoffrey Romer <gromer@google.com>
Date: Wed, 28 Aug 2013 08:14:30 -0700
Raw View
--089e0149d28a30801804e50372cd
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Note that your API/implementation is quite hazardous to use. For example,
the following reasonable-looking code has undefined behavior:

vector<Foo> MakeVector();

for (auto Foo : reversed(MakeVector()) {
  ...
}

This can be fixed by adding C&& overloads which move the parameter into the
container_reverser rather than taking a reference to it.

On Wed, Aug 28, 2013 at 12:54 AM, Bengt Gustafsson <
bengt.gustafsson@beamways.com> wrote:

>  I was suggesting that, as ranges seem to be slow in coming, a simple
> std::reversed() function that works today in all range based for loops
> could be added. As it works also for ranges (if implemented anything like=
 I
> suspect) it would not cause duplicating functionality later.
>
> Also, as reversed() is not so closely related to ranges but works more
> generally I would not want it to be in a special ranges namespace (if the=
re
> is one).
>

reversed() could not be more closely related to ranges. The concept that
the parameter type C models is just exactly the concept of a range:
something you can call begin() and end() on. Consequently, functions like
reversed() are usually referred to as "range adaptors".


>
>
>
> R=C3=B3bert D=C3=A1vid skrev 2013-08-28 02:35:
>
> Wouldn't ranges have some kind of solution to reverse ranges? If
> containers are convertible to ranges, then the reversed ranged based for
> would look something like:
>  for(auto elem : std::ranges::reverse(container)) { ... }
>
> Also shouldn't the "reversed begin" call rbegin(), instead of end()? (And
> end calling rend())
>
> Regards, Robert
>
>
>
> 2013. augusztus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt Gustafsson=
 a
> k=C3=B6vetkez=C5=91t =C3=ADrta:
>>
>>
>> Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:
>> >> I'm thinking whether we should standardize make_reverse_iterator
>> >> as well.  It's fairly useful when dealing with something like C
>> strings.
>> > I tend to agree.
>>
>> Me to, as when I generalized the begin(reverser<C>) to handle classes
>> which don't have a nested type called 'iterator', like regular arrays
>> for instance, I ended up with this, which is not something you want to
>> write too often:
>>
>>      template<typename C> auto begin(container_reverser<C>&
>> cont)->reverse_iterator<**decltype(end(cont.container))> {
>>          return
>> reverse_iterator<decltype(end(**cont.container))>(end(cont.**container))=
;
>>
>>      }
>>
>> Which could be simplified to:
>>
>>      template<typename C> auto begin(container_reverser<C>& cont) {
>>          return make_reverse_iterator(end(**cont.container));
>>      }
>>
>> given make_reverse_iterator() and the new better 'auto' return type
>> handling for functions, which I don't have in VS2012-Nov 2012 CTP.
>>
>> --
>> Bengt Gustafsson
>> CEO, Beamways AB
>> Westmansgatan 37A
>> 582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden
>> +46 13 465 10 85
>> www.beamways.com
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
>
> --
> Bengt Gustafsson
> CEO, Beamways AB
> Westmansgatan 37A
> 582 16 Link=C3=B6ping, Sweden
> +46 13 465 10 85www.beamways.com
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> 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/.

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

<div dir=3D"ltr"><div>Note that your API/implementation is quite hazardous =
to use. For example, the following reasonable-looking code has undefined be=
havior:<br></div><div><br></div><div>vector&lt;Foo&gt; MakeVector();</div>
<div><br></div><div>for (auto Foo : reversed(MakeVector()) {</div><div>=C2=
=A0 ...</div><div>}</div><div><br></div><div>This can be fixed by adding C&=
amp;&amp; overloads which move the parameter into the container_reverser ra=
ther than taking a reference to it.</div>
<div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Aug 28, 2=
013 at 12:54 AM, Bengt Gustafsson <span dir=3D"ltr">&lt;<a href=3D"mailto:b=
engt.gustafsson@beamways.com" target=3D"_blank">bengt.gustafsson@beamways.c=
om</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    I was suggesting that, as ranges seem to be slow in coming, a simple
    std::reversed() function that works today in all range based for
    loops could be added. As it works also for ranges (if implemented
    anything like I suspect) it would not cause duplicating
    functionality later.<br>
    <br>
    Also, as reversed() is not so closely related to ranges but works
    more generally I would not want it to be in a special ranges
    namespace (if there is one).<br></div></blockquote><div><br></div><div>=
reversed() could not be more closely related to ranges. The concept that th=
e parameter type C models is just exactly the concept of a range: something=
 you can call begin() and end() on. Consequently, functions like reversed()=
 are usually referred to as &quot;range adaptors&quot;.</div>
<div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div text=3D"#000000" bgcol=
or=3D"#FFFFFF">
    <br>
    <br>
    <br>
    <div>R=C3=B3bert D=C3=A1vid skrev 2013-08-28 02:35:<br>
    </div><div><div class=3D"h5">
    <blockquote type=3D"cite">
      <div dir=3D"ltr">Wouldn&#39;t ranges have some kind of solution to
        reverse ranges? If containers are convertible to ranges, then
        the reversed ranged based for would look something like:<br>
        <div style=3D"background-color:rgb(250,250,250);border-color:rgb(18=
7,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
            <div><span style=3D"color:#008">for</span><span style=3D"color:=
#660">(</span><span style=3D"color:#008">auto</span><span style> elem </spa=
n><span style=3D"color:#660">:</span><span style> std</span><span style=3D"=
color:#660">::</span><span style>ranges</span><span style=3D"color:#660">::=
</span><span style>reverse</span><span style=3D"color:#660">(</span><span s=
tyle>container</span><span style=3D"color:#660">))</span><span style> </spa=
n><span style=3D"color:#660">{</span><span style> </span><span style=3D"col=
or:#660">...</span><span style> </span><span style=3D"color:#660">}</span><=
/div>

          </code></div>
        <br>
        Also shouldn&#39;t the &quot;reversed begin&quot; call rbegin(), in=
stead of
        end()? (And end calling rend())<br>
        <br>
        Regards, Robert<br>
        <br>
        <br>
        <br>
        2013. augusztus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt
        Gustafsson a k=C3=B6vetkez=C5=91t =C3=ADrta:
        <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
          <br>
          Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:
          <br>
          &gt;&gt; I&#39;m thinking whether we should standardize
          make_reverse_iterator
          <br>
          &gt;&gt; as well. =C2=A0It&#39;s fairly useful when dealing with
          something like C strings.
          <br>
          &gt; I tend to agree.
          <br>
          <br>
          Me to, as when I generalized the begin(reverser&lt;C&gt;) to
          handle classes <br>
          which don&#39;t have a nested type called &#39;iterator&#39;, lik=
e regular
          arrays <br>
          for instance, I ended up with this, which is not something you
          want to <br>
          write too often:
          <br>
          <br>
          =C2=A0 =C2=A0 =C2=A0template&lt;typename C&gt; auto
          begin(container_reverser&lt;C&gt;&amp; <br>
          cont)-&gt;reverse_iterator&lt;<u></u>decltype(end(cont.container)=
)&gt;
          {
          <br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return <br>
          reverse_iterator&lt;decltype(end(<u></u>cont.container))&gt;(end(=
cont.<u></u>container));
          <br>
          =C2=A0 =C2=A0 =C2=A0}
          <br>
          <br>
          Which could be simplified to:
          <br>
          <br>
          =C2=A0 =C2=A0 =C2=A0template&lt;typename C&gt; auto
          begin(container_reverser&lt;C&gt;&amp; cont) {
          <br>
          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return make_reverse_iterator(en=
d(<u></u>cont.container));
          <br>
          =C2=A0 =C2=A0 =C2=A0}
          <br>
          <br>
          given make_reverse_iterator() and the new better &#39;auto&#39; r=
eturn
          type <br>
          handling for functions, which I don&#39;t have in VS2012-Nov 2012
          CTP.
          <br>
          <br>
          -- <br>
          Bengt Gustafsson
          <br>
          CEO, Beamways AB
          <br>
          Westmansgatan 37A
          <br>
          582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden
          <br>
          <a href=3D"tel:%2B46%2013%20465%2010%2085" value=3D"+46134651085"=
 target=3D"_blank">+46 13 465 10 85</a>
          <br>
          <a href=3D"http://www.beamways.com" target=3D"_blank">www.beamway=
s.com</a>
          <br>
          <br>
        </blockquote>
      </div>
      -- <br>
      =C2=A0<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 email to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.o=
rg" 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.o=
rg/group/std-proposals/</a>.<br>
    </blockquote>
    <br>
    </div></div><pre cols=3D"72"><span class=3D"HOEnZb"><font color=3D"#888=
888">--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=C3=B6ping, Sweden
</font></span><div class=3D"im"><a href=3D"tel:%2B46%2013%20465%2010%2085" =
value=3D"+46134651085" target=3D"_blank">+46 13 465 10 85</a>
<a href=3D"http://www.beamways.com" target=3D"_blank">www.beamways.com</a>
</div></pre>
  </div><div class=3D"HOEnZb"><div class=3D"h5">


<p></p>

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

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--089e0149d28a30801804e50372cd--

.


Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Wed, 28 Aug 2013 18:00:49 +0200
Raw View
This is a multi-part message in MIME format.
--------------070102010303030502010300
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable


Geoffrey Romer skrev 2013-08-28 17:14:
> Note that your API/implementation is quite hazardous to use. For=20
> example, the following reasonable-looking code has undefined behavior:
>
> vector<Foo> MakeVector();
>
> for (auto Foo : reversed(MakeVector()) {
>   ...
> }
> This can be fixed by adding C&& overloads which move the parameter=20
> into the container_reverser rather than taking a reference to it.
Yes, I guess that there would have to be an overloaded reversed() for &&=20
references which creates an object of another type that contains the=20
copy of the container.

I guess that any solution (operator| or whatever) would have to tackle=20
that problem.

>
> On Wed, Aug 28, 2013 at 12:54 AM, Bengt Gustafsson=20
> <bengt.gustafsson@beamways.com <mailto:bengt.gustafsson@beamways.com>>=20
> wrote:
>
>     I was suggesting that, as ranges seem to be slow in coming, a
>     simple std::reversed() function that works today in all range
>     based for loops could be added. As it works also for ranges (if
>     implemented anything like I suspect) it would not cause
>     duplicating functionality later.
>
>     Also, as reversed() is not so closely related to ranges but works
>     more generally I would not want it to be in a special ranges
>     namespace (if there is one).
>
>
> reversed() could not be more closely related to ranges. The concept=20
> that the parameter type C models is just exactly the concept of a=20
> range: something you can call begin() and end() on. Consequently,=20
> functions like reversed() are usually referred to as "range adaptors".
Maybe I'm wrong but I was assuming that all of this fuzz about ranges=20
was to finally allow this code:

vector<int> x;

find(x, 10);

-- presumably through vector having a operator range<value_type>() or=20
similar, and an appropriate template range to encapsulate the iterator=20
pair, which then a new overload of find would find in there.

If so my reversed() is orthogonal to this idea, as it works with or=20
without this intermediate:

for (int i: reversed(x))            // No range object involved
    ;

find (reversed(x), 3);            // A range being made from the=20
container_reverser<> object created by reversed()

>
>
>
>     R=C3=B3bert D=C3=A1vid skrev 2013-08-28 02:35:
>>     Wouldn't ranges have some kind of solution to reverse ranges? If
>>     containers are convertible to ranges, then the reversed ranged
>>     based for would look something like:
>>     |
>>     for(autoelem :std::ranges::reverse(container)){...}
>>     |
>>
>>     Also shouldn't the "reversed begin" call rbegin(), instead of
>>     end()? (And end calling rend())
>>
>>     Regards, Robert
>>
>>
>>
>>     2013. augusztus 27., kedd 22:20:47 UTC+2 id=C5=91pontban Bengt
>>     Gustafsson a k=C3=B6vetkez=C5=91t =C3=ADrta:
>>
>>
>>         Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 21:53:
>>         >> I'm thinking whether we should standardize
>>         make_reverse_iterator
>>         >> as well.  It's fairly useful when dealing with something
>>         like C strings.
>>         > I tend to agree.
>>
>>         Me to, as when I generalized the begin(reverser<C>) to handle
>>         classes
>>         which don't have a nested type called 'iterator', like
>>         regular arrays
>>         for instance, I ended up with this, which is not something
>>         you want to
>>         write too often:
>>
>>              template<typename C> auto begin(container_reverser<C>&
>>         cont)->reverse_iterator<decltype(end(cont.container))> {
>>                  return
>>         reverse_iterator<decltype(end(cont.container))>(end(cont.contain=
er));
>>
>>              }
>>
>>         Which could be simplified to:
>>
>>              template<typename C> auto begin(container_reverser<C>&
>>         cont) {
>>                  return make_reverse_iterator(end(cont.container));
>>              }
>>
>>         given make_reverse_iterator() and the new better 'auto'
>>         return type
>>         handling for functions, which I don't have in VS2012-Nov 2012
>>         CTP.
>>
>>         --=20
>>         Bengt Gustafsson
>>         CEO, Beamways AB
>>         Westmansgatan 37A
>>         582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden
>>         +46 13 465 10 85 <tel:%2B46%2013%20465%2010%2085>
>>         www.beamways.com <http://www.beamways.com>
>>
>>     --=20
>>
>>     ---
>>     You received this message because you are subscribed to the
>>     Google Groups "ISO C++ Standard - Future Proposals" group.
>>     To unsubscribe from this group and stop receiving emails from it,
>>     send an 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/.
>
>     --=20
>     Bengt Gustafsson
>     CEO, Beamways AB
>     Westmansgatan 37A
>     582 16 Link=C3=B6ping, Sweden
>     +46 13 465 10 85 <tel:%2B46%2013%20465%2010%2085> www.beamways.com
>     <http://www.beamways.com>
>
>     --=20
>
>     ---
>     You received this message because you are subscribed to the Google
>     Groups "ISO C++ Standard - Future Proposals" group.
>     To unsubscribe from this group and stop receiving emails from it,
>     send an email to std-proposals+unsubscribe@isocpp.org
>     <mailto:std-proposals%2Bunsubscribe@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/.
>
>
> --=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-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at=20
> http://groups.google.com/a/isocpp.org/group/std-proposals/.

--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=C3=B6ping, Sweden
+46 13 465 10 85
www.beamways.com

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an 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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body text=3D"#000000" bgcolor=3D"#FFFFFF">
    <br>
    <div class=3D"moz-cite-prefix">Geoffrey Romer skrev 2013-08-28 17:14:<b=
r>
    </div>
    <blockquote
cite=3D"mid:CA+cyFgvZuB-D64aLcQ6hb0d-3mcJJkgPwKuN+xOhQdKxzW5QSg@mail.gmail.=
com"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>Note that your API/implementation is quite hazardous to
          use. For example, the following reasonable-looking code has
          undefined behavior:<br>
        </div>
        <div><br>
        </div>
        <div>vector&lt;Foo&gt; MakeVector();</div>
        <div><br>
        </div>
        <div>for (auto Foo : reversed(MakeVector()) {</div>
        <div>=C2=A0 ...</div>
        <div>}</div>
        <div>This can be fixed by adding C&amp;&amp; overloads which
          move the parameter into the container_reverser rather than
          taking a reference to it.<br>
        </div>
      </div>
    </blockquote>
    Yes, I guess that there would have to be an overloaded reversed()
    for &amp;&amp; references which creates an object of another type
    that contains the copy of the container.<br>
    <br>
    I guess that any solution (operator| or whatever) would have to
    tackle that problem.<br>
    <br>
    <blockquote
cite=3D"mid:CA+cyFgvZuB-D64aLcQ6hb0d-3mcJJkgPwKuN+xOhQdKxzW5QSg@mail.gmail.=
com"
      type=3D"cite">
      <div dir=3D"ltr">
        <div class=3D"gmail_extra"><br>
          <div class=3D"gmail_quote">On Wed, Aug 28, 2013 at 12:54 AM,
            Bengt Gustafsson <span dir=3D"ltr">&lt;<a
                moz-do-not-send=3D"true"
                href=3D"mailto:bengt.gustafsson@beamways.com"
                target=3D"_blank">bengt.gustafsson@beamways.com</a>&gt;</sp=
an>
            wrote:<br>
            <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text=3D"#000000" bgcolor=3D"#FFFFFF"> I was suggesting
                that, as ranges seem to be slow in coming, a simple
                std::reversed() function that works today in all range
                based for loops could be added. As it works also for
                ranges (if implemented anything like I suspect) it would
                not cause duplicating functionality later.<br>
                <br>
                Also, as reversed() is not so closely related to ranges
                but works more generally I would not want it to be in a
                special ranges namespace (if there is one).<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>reversed() could not be more closely related to ranges.
              The concept that the parameter type C models is just
              exactly the concept of a range: something you can call
              begin() and end() on. Consequently, functions like
              reversed() are usually referred to as "range adaptors".</div>
          </div>
        </div>
      </div>
    </blockquote>
    Maybe I'm wrong but I was assuming that all of this fuzz about
    ranges was to finally allow this code:<br>
    <br>
    vector&lt;int&gt; x;<br>
    <br>
    find(x, 10);<br>
    <br>
    -- presumably through vector having a operator
    range&lt;value_type&gt;() or similar, and an appropriate template
    range to encapsulate the iterator pair, which then a new overload of
    find would find in there.<br>
    <br>
    If so my reversed() is orthogonal to this idea, as it works with or
    without this intermediate:<br>
    <br>
    for (int i: reversed(x))=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0 // No range object involved<br>
    =C2=A0=C2=A0 ;<br>
    <br>
    find (reversed(x), 3);=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0 // A range being made from the
    container_reverser&lt;&gt; object created by reversed()<br>
    <br>
    <blockquote
cite=3D"mid:CA+cyFgvZuB-D64aLcQ6hb0d-3mcJJkgPwKuN+xOhQdKxzW5QSg@mail.gmail.=
com"
      type=3D"cite">
      <div dir=3D"ltr">
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">
            <div>=C2=A0</div>
            <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text=3D"#000000" bgcolor=3D"#FFFFFF"> <br>
                <br>
                <br>
                <div>R=C3=B3bert D=C3=A1vid skrev 2013-08-28 02:35:<br>
                </div>
                <div>
                  <div class=3D"h5">
                    <blockquote type=3D"cite">
                      <div dir=3D"ltr">Wouldn't ranges have some kind of
                        solution to reverse ranges? If containers are
                        convertible to ranges, then the reversed ranged
                        based for would look something like:<br>
                        <div
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code>
                            <div><span style=3D"color:#008">for</span><span
                                style=3D"color:#660">(</span><span
                                style=3D"color:#008">auto</span><span
                                style=3D""> elem </span><span
                                style=3D"color:#660">:</span><span
                                style=3D""> std</span><span
                                style=3D"color:#660">::</span><span
                                style=3D"">ranges</span><span
                                style=3D"color:#660">::</span><span
                                style=3D"">reverse</span><span
                                style=3D"color:#660">(</span><span
                                style=3D"">container</span><span
                                style=3D"color:#660">))</span><span
                                style=3D""> </span><span
                                style=3D"color:#660">{</span><span
                                style=3D""> </span><span
                                style=3D"color:#660">...</span><span
                                style=3D""> </span><span
                                style=3D"color:#660">}</span></div>
                          </code></div>
                        <br>
                        Also shouldn't the "reversed begin" call
                        rbegin(), instead of end()? (And end calling
                        rend())<br>
                        <br>
                        Regards, Robert<br>
                        <br>
                        <br>
                        <br>
                        2013. augusztus 27., kedd 22:20:47 UTC+2
                        id=C5=91pontban Bengt Gustafsson a k=C3=B6vetkez=C5=
=91t =C3=ADrta:
                        <blockquote class=3D"gmail_quote"
                          style=3D"margin:0;margin-left:0.8ex;border-left:1=
px
                          #ccc solid;padding-left:1ex"> <br>
                          Daniel Kr=C3=AF=C2=BF=C2=BDgler skrev 2013-08-27 =
21:53: <br>
                          &gt;&gt; I'm thinking whether we should
                          standardize make_reverse_iterator <br>
                          &gt;&gt; as well. =C2=A0It's fairly useful when
                          dealing with something like C strings. <br>
                          &gt; I tend to agree. <br>
                          <br>
                          Me to, as when I generalized the
                          begin(reverser&lt;C&gt;) to handle classes <br>
                          which don't have a nested type called
                          'iterator', like regular arrays <br>
                          for instance, I ended up with this, which is
                          not something you want to <br>
                          write too often: <br>
                          <br>
                          =C2=A0 =C2=A0 =C2=A0template&lt;typename C&gt; au=
to
                          begin(container_reverser&lt;C&gt;&amp; <br>
                          cont)-&gt;reverse_iterator&lt;decltype(end(cont.c=
ontainer))&gt;

                          { <br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return <br>
                          reverse_iterator&lt;decltype(end(cont.container))=
&gt;(end(cont.container));

                          <br>
                          =C2=A0 =C2=A0 =C2=A0} <br>
                          <br>
                          Which could be simplified to: <br>
                          <br>
                          =C2=A0 =C2=A0 =C2=A0template&lt;typename C&gt; au=
to
                          begin(container_reverser&lt;C&gt;&amp; cont) {
                          <br>
                          =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return make_rev=
erse_iterator(end(cont.container));

                          <br>
                          =C2=A0 =C2=A0 =C2=A0} <br>
                          <br>
                          given make_reverse_iterator() and the new
                          better 'auto' return type <br>
                          handling for functions, which I don't have in
                          VS2012-Nov 2012 CTP. <br>
                          <br>
                          -- <br>
                          Bengt Gustafsson <br>
                          CEO, Beamways AB <br>
                          Westmansgatan 37A <br>
                          582 16 Link=C3=AF=C2=BF=C2=BDping, Sweden <br>
                          <a moz-do-not-send=3D"true"
                            href=3D"tel:%2B46%2013%20465%2010%2085"
                            value=3D"+46134651085" target=3D"_blank">+46 13
                            465 10 85</a> <br>
                          <a moz-do-not-send=3D"true"
                            href=3D"http://www.beamways.com"
                            target=3D"_blank">www.beamways.com</a> <br>
                          <br>
                        </blockquote>
                      </div>
                      -- <br>
                      =C2=A0<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 email to <a
                        moz-do-not-send=3D"true"
                        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
                        moz-do-not-send=3D"true"
                        href=3D"mailto:std-proposals@isocpp.org"
                        target=3D"_blank">std-proposals@isocpp.org</a>.<br>
                      Visit this group at <a moz-do-not-send=3D"true"
                        href=3D"http://groups.google.com/a/isocpp.org/group=
/std-proposals/"
                        target=3D"_blank">http://groups.google.com/a/isocpp=
..org/group/std-proposals/</a>.<br>
                    </blockquote>
                    <br>
                  </div>
                </div>
                <pre cols=3D"72"><span class=3D"HOEnZb"><font color=3D"#888=
888">--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=C3=B6ping, Sweden
</font></span><div class=3D"im"><a moz-do-not-send=3D"true" href=3D"tel:%2B=
46%2013%20465%2010%2085" value=3D"+46134651085" target=3D"_blank">+46 13 46=
5 10 85</a>
<a moz-do-not-send=3D"true" href=3D"http://www.beamways.com" target=3D"_bla=
nk">www.beamways.com</a>
</div></pre>
              </div>
              <div class=3D"HOEnZb">
                <div class=3D"h5">
                  -- <br>
                  =C2=A0<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 email to <a
                    moz-do-not-send=3D"true"
                    href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org"
                    target=3D"_blank">std-proposals+unsubscribe@isocpp.org<=
/a>.<br>
                  To post to this group, send email to <a
                    moz-do-not-send=3D"true"
                    href=3D"mailto:std-proposals@isocpp.org"
                    target=3D"_blank">std-proposals@isocpp.org</a>.<br>
                  Visit this group at <a moz-do-not-send=3D"true"
                    href=3D"http://groups.google.com/a/isocpp.org/group/std=
-proposals/"
                    target=3D"_blank">http://groups.google.com/a/isocpp.org=
/group/std-proposals/</a>.<br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
      -- <br>
      =C2=A0<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 email to <a class=3D"moz-txt-link-abbreviated" href=3D"mailto=
:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org=
</a>.<br>
      To post to this group, send email to <a class=3D"moz-txt-link-abbrevi=
ated" href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>=
..<br>
      Visit this group at <a moz-do-not-send=3D"true"
        href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/"=
>http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br>
    </blockquote>
    <br>
    <pre class=3D"moz-signature" cols=3D"72">--=20
Bengt Gustafsson
CEO, Beamways AB
Westmansgatan 37A
582 16 Link=C3=B6ping, Sweden
+46 13 465 10 85
<a class=3D"moz-txt-link-abbreviated" href=3D"http://www.beamways.com">www.=
beamways.com</a>
</pre>
  </body>
</html>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--------------070102010303030502010300--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Wed, 28 Aug 2013 12:09:22 -0400
Raw View
On Wed, Aug 28, 2013 at 12:00 PM, Bengt Gustafsson
<bengt.gustafsson@beamways.com> wrote:
> Maybe I'm wrong but I was assuming that all of this fuzz about ranges was to
> finally allow this code:
>
> vector<int> x;
>
> find(x, 10);

Not "finally", but yes.

> -- presumably through vector having a operator range<value_type>() or
> similar, and an appropriate template range to encapsulate the iterator pair,
> which then a new overload of find would find in there.

The currently plan is to regard a traversable container as a range
instead of using a proxy type:

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3686.html

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jonathan Wakely <cxx@kayari.org>
Date: Wed, 28 Aug 2013 10:24:08 -0700 (PDT)
Raw View
------=_Part_318_2507721.1377710648264
Content-Type: text/plain; charset=ISO-8859-1



On Wednesday, August 28, 2013 4:14:30 PM UTC+1, Geoffrey Romer wrote:
>
> Note that your API/implementation is quite hazardous to use. For example,
> the following reasonable-looking code has undefined behavior:
>
> vector<Foo> MakeVector();
>
> for (auto Foo : reversed(MakeVector()) {
>   ...
> }
>
> This can be fixed by adding C&& overloads which move the parameter into
> the container_reverser rather than taking a reference to it.
>
>
No need to overload, just store a member of type C, not C&, and add some
perfect forwarding:

template<typename C> struct container_reverser {
container_reverser(C&& cont) : container(std::forward<C>(cont)) {}

C container;
};

and then take a parameter of type C&&:

template<typename C> container_reverser<C> reversed(C&& cont)
{
return container_reverser<C>(std::forward<C>(cont));
}

When reversing an lvalue, C will be an lvalue-reference type, and the
adaptor will have an lvalue-reference member, when reversing an rvalue the
adaptor will hold an object type which will be move-constructed from the
rvalue argument.

This way the adaptor takes ownership of rvalues but holds a reference to
lvalues.

--

---
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_318_2507721.1377710648264
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, August 28, 2013 4:14:30 PM UTC+1, Ge=
offrey Romer wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><div>Note that your API/implementation is quite hazardous to use. For=
 example, the following reasonable-looking code has undefined behavior:<br>=
</div><div><br></div><div>vector&lt;Foo&gt; MakeVector();</div>
<div><br></div><div>for (auto Foo : reversed(MakeVector()) {</div><div>&nbs=
p; ...</div><div>}</div><div><br></div><div>This can be fixed by adding C&a=
mp;&amp; overloads which move the parameter into the container_reverser rat=
her than taking a reference to it.</div>
<div><br></div></div></blockquote><div><br>No need to overload, just store =
a member of type C, not C&amp;, and add some perfect forwarding:<br><br><di=
v><font face=3D"courier new, monospace">template&lt;typename C&gt; struct c=
ontainer_reverser {</font></div><div><font face=3D"courier new, monospace">=
<span style=3D"white-space:pre"> </span>container_reverser(C&amp;&amp; cont=
) : container(std::forward&lt;C&gt;(cont)) {}</font></div><div><font face=
=3D"courier new, monospace"><br></font></div><div><font face=3D"courier new=
, monospace"><span style=3D"white-space:pre"> </span>C container;</font></d=
iv><div><font face=3D"courier new, monospace">};</font></div><br>and then t=
ake a parameter of type C&amp;&amp;:<br><br><div><font face=3D"courier new,=
 monospace">template&lt;typename C&gt; container_reverser&lt;C&gt; reversed=
(C&amp;&amp; cont)</font></div><div><font face=3D"courier new, monospace">{=
</font></div><div><font face=3D"courier new, monospace"><span style=3D"whit=
e-space:pre"> </span>return container_reverser&lt;C&gt;(std::forward&lt;C&g=
t;(cont));</font></div><div><font face=3D"courier new, monospace">}</font><=
/div></div><br>When reversing an lvalue, C will be an lvalue-reference type=
, and the adaptor will have an lvalue-reference member, when reversing an r=
value the adaptor will hold an object type which will be move-constructed f=
rom the rvalue argument.<br><br>This way the adaptor takes ownership of rva=
lues but holds a reference to lvalues.<br><br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_318_2507721.1377710648264--

.


Author: Bengt Gustafsson <bengt.gustafsson@beamways.com>
Date: Thu, 29 Aug 2013 01:50:29 -0700 (PDT)
Raw View
------=_Part_6406_30363217.1377766229644
Content-Type: text/plain; charset=ISO-8859-1

Thanks Jonathan for the nice code improvement. I'm still trying to get up
to speed on (p)rvalue references...

I read the paper
http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3686.html you
directed me at Zhihao. It does not yet contain new overloads to the
standard algorithms but I assume this is coming up.

It seems that this debate is starting to boil down to whether the syntax
for reversing is to be

reversed(container)

or

container | reversed

For me the first one was logical as it is just a function and does the work
of a function. The second version seems to stem from boost. I don't see a
large advantage but I do see that it requires a special tag type and an
object of that type which "triggers" the overloaded operator|. Isn't this
added complexity of implementation enough to prefer the function-ish
approach? That is, unless I'm missing some important usage advantage to the
| operator used as a "general modifier" operator.

The return type of this function or operator| would anyhow contain two
iterators. Is there a consensus to use std::pair<> for this or is a new
template class envisioned? The return type of equal_range indicates that
std::pair would be a good choice as traversable::begin(pair<>) and
end(pair<>) would make it work as is.

Finally a question: The paper N3686 spells Traversable with a capital T, is
this a new naming convention for the standard library or can a lower case
version be expected for the actual standard text? If you do using namespace
std; a capiralized name could more easily interfer with user code as most
code nowadays seems to use a camel case convention. Keeping the standard
library all lower case reduces these risks.


>

--

---
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_6406_30363217.1377766229644
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks Jonathan for the nice code improvement. I'm still t=
rying to get up to speed on (p)rvalue references...<div><br></div><div>I re=
ad the paper&nbsp;<a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/pa=
pers/2013/n3686.html" target=3D"_blank" style=3D"cursor: pointer;">http://w=
ww.open-std.org/JTC1/<wbr>SC22/WG21/docs/papers/2013/<wbr>n3686.html</a>&nb=
sp;you directed me at&nbsp;Zhihao. It does not yet contain new overloads to=
 the standard algorithms but I assume this is coming up.</div><div><br></di=
v><div>It seems that this debate is starting to boil down to whether the sy=
ntax for reversing is to be</div><div><br></div><div>reversed(container)</d=
iv><div><br></div><div>or</div><div><br></div><div>container | reversed</di=
v><div><br></div><div>For me the first one was logical as it is just a func=
tion and does the work of a function. The second version seems to stem from=
 boost. I don't see a large advantage but I do see that it requires a speci=
al tag type and an object of that type which "triggers" the overloaded oper=
ator|. Isn't this added complexity of implementation enough to prefer the f=
unction-ish approach? That is, unless I'm missing some important usage adva=
ntage to the | operator used as a "general modifier" operator.</div><div><b=
r></div><div>The return type of this function or operator| would anyhow con=
tain two iterators. Is there a consensus to use std::pair&lt;&gt; for this =
or is a new template class envisioned? The return type of equal_range indic=
ates that std::pair would be a good choice as traversable::begin(pair&lt;&g=
t;) and end(pair&lt;&gt;) would make it work as is.</div><div><br>Finally a=
 question: The paper N3686 spells Traversable with a capital T, is this a n=
ew naming convention for the standard library or can a lower case version b=
e expected for the actual standard text? If you do using namespace std; a c=
apiralized name could more easily interfer with user code as most code nowa=
days seems to use a camel case convention. Keeping the standard library all=
 lower case reduces these risks.<br><br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr"><br></div></blockquote></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_6406_30363217.1377766229644--

.


Author: Jonathan Wakely <cxx@kayari.org>
Date: Thu, 29 Aug 2013 04:34:06 -0700 (PDT)
Raw View
------=_Part_6594_24490011.1377776046811
Content-Type: text/plain; charset=ISO-8859-1



On Thursday, August 29, 2013 9:50:29 AM UTC+1, Bengt Gustafsson wrote:
>
> Thanks Jonathan for the nice code improvement. I'm still trying to get up
> to speed on (p)rvalue references...
>
> I read the paper
> http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3686.html you
> directed me at Zhihao. It does not yet contain new overloads to the
> standard algorithms but I assume this is coming up.
>
> It seems that this debate is starting to boil down to whether the syntax
> for reversing is to be
>
> reversed(container)
>
> or
>
> container | reversed
>
> For me the first one was logical as it is just a function and does the
> work of a function. The second version seems to stem from boost. I don't
> see a large advantage but I do see that it requires a special tag type and
> an object of that type which "triggers" the overloaded operator|. Isn't
> this added complexity of implementation enough to prefer the function-ish
> approach? That is, unless I'm missing some important usage advantage to the
> | operator used as a "general modifier" operator.
>
>
An advantage of the Boost.Range syntax is that it's arguably easier to read:

    r | sort | reverse | filter(p)

than to read

    filtered(reversed(sorted(r)), p)

However I would not assume that the ranges sub-group are going to do
everything Boost.Range does.


The return type of this function or operator| would anyhow contain two
> iterators. Is there a consensus to use std::pair<> for this or is a new
> template class envisioned? The return type of equal_range indicates that
> std::pair would be a good choice as traversable::begin(pair<>) and
> end(pair<>) would make it work as is.
>
>
std::equal_range would probably not return a std::pair if we wrote it
today. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2995.pdf

IIRC the range group wanted some kind of iterator_pair type which is
explicitly a Traversable type, whereas a std::pair<It,It> might not be
traversable i.e. p.second might not be reachable from p.first.



> Finally a question: The paper N3686 spells Traversable with a capital T,
> is this a new naming convention for the standard library or can a lower
> case version be expected for the actual standard text? If you do using
> namespace std; a capiralized name could more easily interfer with user code
> as most code nowadays seems to use a camel case convention. Keeping the
> standard library all lower case reduces these risks.
>
>
Traversable is a concept, like CopyConstructible, not a type.


--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_6594_24490011.1377776046811
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, August 29, 2013 9:50:29 AM UTC+1, Ben=
gt Gustafsson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Thanks Jonathan for the nice code improvement. I'm still trying to=
 get up to speed on (p)rvalue references...<div><br></div><div>I read the p=
aper&nbsp;<a href=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/201=
3/n3686.html" target=3D"_blank">http://www.open-std.org/<wbr>JTC1/SC22/WG21=
/docs/papers/<wbr>2013/n3686.html</a>&nbsp;you directed me at&nbsp;Zhihao. =
It does not yet contain new overloads to the standard algorithms but I assu=
me this is coming up.</div><div><br></div><div>It seems that this debate is=
 starting to boil down to whether the syntax for reversing is to be</div><d=
iv><br></div><div>reversed(container)</div><div><br></div><div>or</div><div=
><br></div><div>container | reversed</div><div><br></div><div>For me the fi=
rst one was logical as it is just a function and does the work of a functio=
n. The second version seems to stem from boost. I don't see a large advanta=
ge but I do see that it requires a special tag type and an object of that t=
ype which "triggers" the overloaded operator|. Isn't this added complexity =
of implementation enough to prefer the function-ish approach? That is, unle=
ss I'm missing some important usage advantage to the | operator used as a "=
general modifier" operator.</div><div><br></div></div></blockquote><div><br=
>An advantage of the Boost.Range syntax is that it's arguably easier to rea=
d:<br><br>&nbsp;&nbsp;&nbsp; r | sort | reverse | filter(p)<br><br>than to =
read<br><br>&nbsp;&nbsp;&nbsp; filtered(reversed(sorted(r)), p)<br><br>Howe=
ver I would not assume that the ranges sub-group are going to do everything=
 Boost.Range does. <br><br><br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
 1ex;"><div dir=3D"ltr"><div></div><div>The return type of this function or=
 operator| would anyhow contain two iterators. Is there a consensus to use =
std::pair&lt;&gt; for this or is a new template class envisioned? The retur=
n type of equal_range indicates that std::pair would be a good choice as tr=
aversable::begin(pair&lt;&gt;) and end(pair&lt;&gt;) would make it work as =
is.</div><div><br></div></div></blockquote><div><br>std::equal_range would =
probably not return a std::pair if we wrote it today. See http://www.open-s=
td.org/jtc1/sc22/wg21/docs/papers/2009/n2995.pdf<br><br>IIRC the range grou=
p wanted some kind of iterator_pair type which is explicitly a Traversable =
type, whereas a std::pair&lt;It,It&gt; might not be traversable i.e. p.seco=
nd might not be reachable from p.first.<br><br>&nbsp;</div><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>Finally a question: The =
paper N3686 spells Traversable with a capital T, is this a new naming conve=
ntion for the standard library or can a lower case version be expected for =
the actual standard text? If you do using namespace std; a capiralized name=
 could more easily interfer with user code as most code nowadays seems to u=
se a camel case convention. Keeping the standard library all lower case red=
uces these risks.<br><br></div></div></blockquote><div><br>Traversable is a=
 concept, like CopyConstructible, not a type.<br>&nbsp;<br></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_6594_24490011.1377776046811--

.


Author: Jonathan Wakely <cxx@kayari.org>
Date: Thu, 29 Aug 2013 04:36:03 -0700 (PDT)
Raw View
------=_Part_3475_21726157.1377776163481
Content-Type: text/plain; charset=ISO-8859-1



On Thursday, August 29, 2013 12:34:06 PM UTC+1, Jonathan Wakely wrote:
>
> An advantage of the Boost.Range syntax is that it's arguably easier to
> read:
>
>     r | sort | reverse | filter(p)
>
> than to read
>
>     filtered(reversed(sorted(r)), p)
>

That's true for some people anyway. Everyone else should lrn2unix  ;)


--

---
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_3475_21726157.1377776163481
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Thursday, August 29, 2013 12:34:06 PM UTC+1, Jo=
nathan Wakely wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">An advantage of the Boost.Range syntax is that it's arguably easie=
r to read:<br><div><br>&nbsp;&nbsp;&nbsp; r | sort | reverse | filter(p)<br=
><br>than to read<br><br>&nbsp;&nbsp;&nbsp; filtered(reversed(sorted(r)), p=
)</div></div></blockquote><div><br>That's true for some people anyway. Ever=
yone else should lrn2unix&nbsp; ;)<br>&nbsp;<br></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_3475_21726157.1377776163481--

.