Topic: Range class


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Sat, 24 May 2014 13:09:47 -0700 (PDT)
Raw View
------=_Part_249_9351552.1400962187583
Content-Type: text/plain; charset=UTF-8

One part of the syntax that I've never liked, is the standard

for (initialiser; continuation_condition; iterator)

arising from C, especially when what you want most of the time is a simple
counter.

What would be nice would be to have a class along the following lines:

template <typename T>
class range {
  T from;
  T to;
public:
  inline range(T start, T finish) : from {start}, to {++finish} {}


  // usual constructors, assignments, typedefs, etc.


  inline begin() const {return from; }
  inline end() const {return to; }
};

This would permit code like the following:

for (auto i : std::range(0, 7))
  // ...

Better still if there was a new operator .. introduced so that, for example,

for (auto i : 0 .. 7)
  // ...

would be syntactic sugar for the above, but that's probably pushing things
too much ;)


--

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

<div dir=3D"ltr">One part of the syntax that I've never liked, is the stand=
ard<div><br></div><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-wor=
d;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"col=
or: #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">initialiser</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> continuation_condition</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> iterator</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span></div></code></div><div><br></div><div>arising from C,=
 especially when what you want most of the time is a simple counter.</div><=
div><br>What would be nice would be to have a class along the following lin=
es:</div><div><br></div><div class=3D"prettyprint" style=3D"background-colo=
r: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: bre=
ak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">template</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">typename</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> range </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; T </span><span style=3D"color: #008;" class=3D"styled-by-prettify">fr=
om</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; T to</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">inline</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> range</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">T start</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T finish</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">from</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">start</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">},</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> to </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">{++</span><span style=3D"color: #000;" class=3D"styled-by-prettify">fi=
nish</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 s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{}</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br><br><br>&nbsp; </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">// usual constructors, =
assignments, typedefs, etc.</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br><br>&nbsp; </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">inline</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">begin</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: #008;" class=3D"styled-by-prettify">const</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">from</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br>&nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">inline</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">end</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">return</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> to</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span></div></code></div=
><div><br></div><div>This would permit code like the following:</div><div><=
br></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border: 1px solid rgb(187, 187, 187); 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: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> i </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">range</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">7</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">))</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&n=
bsp; </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ..=
..</span></div></code></div><div><br></div><div>Better still if there was a =
new operator .. introduced so that, for example,</div><div><br></div><div c=
lass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border:=
 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">for</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #066;" class=3D"styled-by-prettify">0</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"styl=
ed-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pre=
ttify">7</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; =
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ...</sp=
an></div></code></div><div><br></div><div>would be syntactic sugar for the =
above, but that's probably pushing things too much ;)<br></div><div><br></d=
iv><div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&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_249_9351552.1400962187583--

.


Author: Diggory Blake <diggsey@googlemail.com>
Date: Sat, 24 May 2014 13:37:01 -0700 (PDT)
Raw View
------=_Part_1449_23417015.1400963821999
Content-Type: text/plain; charset=UTF-8

That would be great assuming nothing like it already exists, although
std::range shouldn't increment the "to" parameter. std::range(x,y) should
just return 'x' and 'y' directly for begin()/end(). Something close to the
nice syntax of "0 .. 7" can probably be achieved with user defined
literals. A two dot version would be inclusive (and so increment 'y' before
passing it to std::range) while a three dot version would be exclusive and
so just pass the parameters through directly, as that seems to be a fairly
standard notation for inclusive vs exclusive ranges.

On Saturday, 24 May 2014 21:09:47 UTC+1, Douglas Boffey wrote:
>
> One part of the syntax that I've never liked, is the standard
>
> for (initialiser; continuation_condition; iterator)
>
> arising from C, especially when what you want most of the time is a simple
> counter.
>
> What would be nice would be to have a class along the following lines:
>
> template <typename T>
> class range {
>   T from;
>   T to;
> public:
>   inline range(T start, T finish) : from {start}, to {++finish} {}
>
>
>   // usual constructors, assignments, typedefs, etc.
>
>
>   inline begin() const {return from; }
>   inline end() const {return to; }
> };
>
> This would permit code like the following:
>
> for (auto i : std::range(0, 7))
>   // ...
>
> Better still if there was a new operator .. introduced so that, for
> example,
>
> for (auto i : 0 .. 7)
>   // ...
>
> would be syntactic sugar for the above, but that's probably pushing things
> too much ;)
>
>
>

--

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

<div dir=3D"ltr">That would be great assuming nothing like it already exist=
s, although std::range shouldn't increment the "to" parameter. std::range(x=
,y) should just return 'x' and 'y' directly for begin()/end(). Something cl=
ose to the nice syntax of "0 .. 7" can probably be achieved with user defin=
ed literals. A two dot version would be inclusive (and so increment 'y' bef=
ore passing it to std::range) while a three dot version would be exclusive =
and so just pass the parameters through directly, as that seems to be a fai=
rly standard notation for inclusive vs exclusive ranges.<br><br>On Saturday=
, 24 May 2014 21:09:47 UTC+1, Douglas Boffey  wrote:<blockquote class=3D"gm=
ail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc soli=
d;padding-left: 1ex;"><div dir=3D"ltr">One part of the syntax that I've nev=
er liked, is the standard<div><br></div><div style=3D"background-color:rgb(=
250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code>=
<div><span style=3D"color:#008">for</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">(</span><span style=3D"color:#000">initialiser=
</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> conti=
nuation_condition</span><span style=3D"color:#660">;</span><span style=3D"c=
olor:#000"> iterator</span><span style=3D"color:#660">)</span><span style=
=3D"color:#000"><br></span></div></code></div><div><br></div><div>arising f=
rom C, especially when what you want most of the time is a simple counter.<=
/div><div><br>What would be nice would be to have a class along the followi=
ng lines:</div><div><br></div><div style=3D"background-color:rgb(250,250,25=
0);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><span=
 style=3D"color:#008">template</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">&lt;</span><span style=3D"color:#008">typename</spa=
n><span style=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#008">class</sp=
an><span style=3D"color:#000"> range </span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br>&nbsp; T </span><span style=3D"color:#00=
8">from</span><span style=3D"color:#660">;</span><span style=3D"color:#000"=
><br>&nbsp; T to</span><span style=3D"color:#660">;</span><span style=3D"co=
lor:#000"><br></span><span style=3D"color:#008">public</span><span style=3D=
"color:#660">:</span><span style=3D"color:#000"><br>&nbsp; </span><span sty=
le=3D"color:#008">inline</span><span style=3D"color:#000"> range</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#000">T start</span><sp=
an style=3D"color:#660">,</span><span style=3D"color:#000"> T finish</span>=
<span style=3D"color:#660">)</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">from</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">{</span><span style=3D"color:#000">start</span><span style=
=3D"color:#660">},</span><span style=3D"color:#000"> to </span><span style=
=3D"color:#660">{++</span><span style=3D"color:#000">finish</span><span sty=
le=3D"color:#660">}</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">{}</span><span style=3D"color:#000"><br><br><br>&nbsp; </span>=
<span style=3D"color:#800">// usual constructors, assignments, typedefs, et=
c.</span><span style=3D"color:#000"><br><br><br>&nbsp; </span><span style=
=3D"color:#008">inline</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">begin</span><span style=3D"color:#660">()</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">const</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"c=
olor:#008">return</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">from</span><span style=3D"color:#660">;</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">}</span><span style=3D"color:#0=
00"><br>&nbsp; </span><span style=3D"color:#008">inline</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">end</span><span style=3D=
"color:#660">()</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#008">const</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">{</span><span style=3D"color:#008">return</span><span style=3D"colo=
r:#000"> to</span><span style=3D"color:#660">;</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">}</span><span style=3D"color:#000">=
<br></span><span style=3D"color:#660">};</span></div></code></div><div><br>=
</div><div>This would permit code like the following:</div><div><br></div><=
div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,187=
,187);word-wrap:break-word"><code><div><span style=3D"color:#008">for</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#008">auto</span><span style=3D"color:#000"> i </span><spa=
n style=3D"color:#660">:</span><span style=3D"color:#000"> std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">range</span><span =
style=3D"color:#660">(</span><span style=3D"color:#066">0</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#066">7</span><span style=3D"color:#660">))</span><span style=3D"color=
:#000"><br>&nbsp; </span><span style=3D"color:#800">// ...</span></div></co=
de></div><div><br></div><div>Better still if there was a new operator .. in=
troduced so that, for example,</div><div><br></div><div style=3D"background=
-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-w=
ord"><code><div><span style=3D"color:#008">for</span><span style=3D"color:#=
000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#008">=
auto</span><span style=3D"color:#000"> i </span><span style=3D"color:#660">=
:</span><span style=3D"color:#000"> </span><span style=3D"color:#066">0</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">..</span><=
span style=3D"color:#000"> </span><span style=3D"color:#066">7</span><span =
style=3D"color:#660">)</span><span style=3D"color:#000"><br>&nbsp; </span><=
span style=3D"color:#800">// ...</span></div></code></div><div><br></div><d=
iv>would be syntactic sugar for the above, but that's probably pushing thin=
gs too much ;)<br></div><div><br></div><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_1449_23417015.1400963821999--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 24 May 2014 15:24:50 -0700 (PDT)
Raw View
------=_Part_399_7400756.1400970291063
Content-Type: text/plain; charset=UTF-8

Something like this:

struct range
{
 struct range_iterator
 {
  int i;
  int stop;
  range_iterator(int a, int b) :i(a), stop(b) {}

  range_iterator& operator++()
  {
   i++;
   return *this;
  }


  int operator*()
  {
   return i;
  }
 };
 range_iterator x;
 range_iterator finish;
 range(int i1, int stop1) :x(i1,stop1+1), finish(stop1+1,stop1+1) {}

 range_iterator& begin() { return x; }
 range_iterator& end() { return finish; }
};

Some time ago I experimented with such definitions. You can try and define
even ranges with steps: range(100,2,-2).
My opinion is that they are not as efficient as standard 'for' loops, but
look good though.

On Saturday, May 24, 2014 9:09:47 PM UTC+1, Douglas Boffey wrote:

> One part of the syntax that I've never liked, is the standard
>
> for (initialiser; continuation_condition; iterator)
>
> arising from C, especially when what you want most of the time is a simple
> counter.
>
> What would be nice would be to have a class along the following lines:
>
> template <typename T>
> class range {
>   T from;
>   T to;
> public:
>   inline range(T start, T finish) : from {start}, to {++finish} {}
>
>
>   // usual constructors, assignments, typedefs, etc.
>
>
>   inline begin() const {return from; }
>   inline end() const {return to; }
> };
>
> This would permit code like the following:
>
> for (auto i : std::range(0, 7))
>   // ...
>
> Better still if there was a new operator .. introduced so that, for
> example,
>
> for (auto i : 0 .. 7)
>   // ...
>
> would be syntactic sugar for the above, but that's probably pushing things
> too much ;)
>
>
>

--

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

<div dir=3D"ltr"><div>Something like this:</div><div><br></div><div>struct =
range<br>{<br>&nbsp;struct range_iterator<br>&nbsp;{<br>&nbsp;&nbsp;int i;<=
br>&nbsp;&nbsp;int stop;<br>&nbsp;&nbsp;range_iterator(int a, int b) :i(a),=
 stop(b) {}<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;range_iterator&amp; operator++()=
<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;i++;<br>&nbsp;&nbsp;&nbsp;return *th=
is;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;</div><div>&nbsp;&nbsp;=
int operator*()<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;return i;<br>&nbsp;&n=
bsp;}&nbsp;&nbsp;<br>&nbsp;};</div><div>&nbsp;range_iterator x;<br>&nbsp;ra=
nge_iterator finish;</div><div>&nbsp;range(int i1, int stop1) :x(i1,stop1+1=
), finish(stop1+1,stop1+1) {}<br>&nbsp;<br>&nbsp;range_iterator&amp; begin(=
) { return x; }<br>&nbsp;range_iterator&amp; end() { return finish; }<br>};=
<br></div><div><br></div><div>Some time ago I experimented with such defini=
tions. You can try and define even ranges with steps: range(100,2,-2).</div=
><div>My opinion is that they are not as efficient as standard 'for' loops,=
 but look good though.</div><div><br>On Saturday, May 24, 2014 9:09:47 PM U=
TC+1, Douglas Boffey 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"l=
tr">One part of the syntax that I've never liked, is the standard<div><br><=
/div><div style=3D"border: 1px solid rgb(187, 187, 187); border-image: none=
; -ms-word-wrap: break-word; background-color: rgb(250, 250, 250);"><code><=
div><span style=3D"color: rgb(0, 0, 136);">for</span><span style=3D"color: =
rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">(</span><sp=
an style=3D"color: rgb(0, 0, 0);">initialiser</span><span style=3D"color: r=
gb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"> continuatio=
n_condition</span><span style=3D"color: rgb(102, 102, 0);">;</span><span st=
yle=3D"color: rgb(0, 0, 0);"> iterator</span><span style=3D"color: rgb(102,=
 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"><br></span></div></=
code></div><div><br></div><div>arising from C, especially when what you wan=
t most of the time is a simple counter.</div><div><br>What would be nice wo=
uld be to have a class along the following lines:</div><div><br></div><div =
style=3D"border: 1px solid rgb(187, 187, 187); border-image: none; -ms-word=
-wrap: break-word; background-color: rgb(250, 250, 250);"><code><div><span =
style=3D"color: rgb(0, 0, 136);">template</span><span style=3D"color: rgb(0=
, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span=
 style=3D"color: rgb(0, 0, 136);">typename</span><span style=3D"color: rgb(=
0, 0, 0);"> T</span><span style=3D"color: rgb(102, 102, 0);">&gt;</span><sp=
an style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(0, 0=
, 136);">class</span><span style=3D"color: rgb(0, 0, 0);"> range </span><sp=
an style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, =
0, 0);"><br>&nbsp; T </span><span style=3D"color: rgb(0, 0, 136);">from</sp=
an><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: r=
gb(0, 0, 0);"><br>&nbsp; T to</span><span style=3D"color: rgb(102, 102, 0);=
">;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"co=
lor: rgb(0, 0, 136);">public</span><span style=3D"color: rgb(102, 102, 0);"=
>:</span><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; </span><span style=
=3D"color: rgb(0, 0, 136);">inline</span><span style=3D"color: rgb(0, 0, 0)=
;"> range</span><span style=3D"color: rgb(102, 102, 0);">(</span><span styl=
e=3D"color: rgb(0, 0, 0);">T start</span><span style=3D"color: rgb(102, 102=
, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> T finish</span><span s=
tyle=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0=
);"> </span><span style=3D"color: rgb(102, 102, 0);">:</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">from<=
/span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rg=
b(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 0);">start</span><=
span style=3D"color: rgb(102, 102, 0);">},</span><span style=3D"color: rgb(=
0, 0, 0);"> to </span><span style=3D"color: rgb(102, 102, 0);">{++</span><s=
pan style=3D"color: rgb(0, 0, 0);">finish</span><span style=3D"color: rgb(1=
02, 102, 0);">}</span><span style=3D"color: rgb(0, 0, 0);"> </span><span st=
yle=3D"color: rgb(102, 102, 0);">{}</span><span style=3D"color: rgb(0, 0, 0=
);"><br><br><br>&nbsp; </span><span style=3D"color: rgb(136, 0, 0);">// usu=
al constructors, assignments, typedefs, etc.</span><span style=3D"color: rg=
b(0, 0, 0);"><br><br><br>&nbsp; </span><span style=3D"color: rgb(0, 0, 136)=
;">inline</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D=
"color: rgb(0, 0, 136);">begin</span><span style=3D"color: rgb(102, 102, 0)=
;">()</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(0, 0, 136);">const</span><span style=3D"color: rgb(0, 0, 0);"> </sp=
an><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: r=
gb(0, 0, 136);">return</span><span style=3D"color: rgb(0, 0, 0);"> </span><=
span style=3D"color: rgb(0, 0, 136);">from</span><span style=3D"color: rgb(=
102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"> </span><span s=
tyle=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0, 0, 0=
);"><br>&nbsp; </span><span style=3D"color: rgb(0, 0, 136);">inline</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0,=
 136);">end</span><span style=3D"color: rgb(102, 102, 0);">()</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);=
">const</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0, 136);">ret=
urn</span><span style=3D"color: rgb(0, 0, 0);"> to</span><span style=3D"col=
or: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"> </span=
><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb=
(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">};</span></=
div></code></div><div><br></div><div>This would permit code like the follow=
ing:</div><div><br></div><div style=3D"border: 1px solid rgb(187, 187, 187)=
; border-image: none; -ms-word-wrap: break-word; background-color: rgb(250,=
 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 136);">for</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 1=
02, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">auto</span><span st=
yle=3D"color: rgb(0, 0, 0);"> i </span><span style=3D"color: rgb(102, 102, =
0);">:</span><span style=3D"color: rgb(0, 0, 0);"> std</span><span style=3D=
"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">ra=
nge</span><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"c=
olor: rgb(0, 102, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">,=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(0, 102, 102);">7</span><span style=3D"color: rgb(102, 102, 0);">))</span=
><span style=3D"color: rgb(0, 0, 0);"><br>&nbsp; </span><span style=3D"colo=
r: rgb(136, 0, 0);">// ...</span></div></code></div><div><br></div><div>Bet=
ter still if there was a new operator .. introduced so that, for example,</=
div><div><br></div><div style=3D"border: 1px solid rgb(187, 187, 187); bord=
er-image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, =
250);"><code><div><span style=3D"color: rgb(0, 0, 136);">for</span><span st=
yle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0)=
;">(</span><span style=3D"color: rgb(0, 0, 136);">auto</span><span style=3D=
"color: rgb(0, 0, 0);"> i </span><span style=3D"color: rgb(102, 102, 0);">:=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(0, 102, 102);">0</span><span style=3D"color: rgb(0, 0, 0);"> </span><spa=
n style=3D"color: rgb(102, 102, 0);">..</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">7</span><span styl=
e=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"=
><br>&nbsp; </span><span style=3D"color: rgb(136, 0, 0);">// ...</span></di=
v></code></div><div><br></div><div>would be syntactic sugar for the above, =
but that's probably pushing things too much ;)<br></div><div><br></div><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_399_7400756.1400970291063--

.


Author: Greg Marr <gregmmarr@gmail.com>
Date: Sun, 25 May 2014 18:45:20 -0700 (PDT)
Raw View
------=_Part_514_26395563.1401068720994
Content-Type: text/plain; charset=UTF-8

On Saturday, May 24, 2014 4:09:47 PM UTC-4, Douglas Boffey wrote:
>
> What would be nice would be to have a class along the following lines:
>
> template <typename T>
> class range {
>   T from;
>   T to;
> public:
>   inline range(T start, T finish) : from {start}, to {++finish} {}
>
>
>   // usual constructors, assignments, typedefs, etc.
>
>
>   inline begin() const {return from; }
>   inline end() const {return to; }
> };
>
> This would permit code like the following:
>
> for (auto i : std::range(0, 7))
>   // ...
>
> Better still if there was a new operator .. introduced so that, for
> example,
>
> for (auto i : 0 .. 7)
>   // ...
>
> would be syntactic sugar for the above, but that's probably pushing things
> too much ;)
>

Have you looked at the std::integer_sequence and std::make_index_sequence
proposal?

http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3658.html

--

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

<div dir=3D"ltr">On Saturday, May 24, 2014 4:09:47 PM UTC-4, Douglas Boffey=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>W=
hat would be nice would be to have a class along the following lines:</div>=
<div><br></div><div style=3D"background-color:rgb(250,250,250);border:1px s=
olid rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"color=
:#008">template</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660">&lt;</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">&gt;</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">class</span><span sty=
le=3D"color:#000"> range </span><span style=3D"color:#660">{</span><span st=
yle=3D"color:#000"><br>&nbsp; T </span><span style=3D"color:#008">from</spa=
n><span style=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbsp; =
T to</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#008">public</span><span style=3D"color:#660"=
>:</span><span style=3D"color:#000"><br>&nbsp; </span><span style=3D"color:=
#008">inline</span><span style=3D"color:#000"> range</span><span style=3D"c=
olor:#660">(</span><span style=3D"color:#000">T start</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> T finish</span><span style=
=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">:</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">from</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000">start</span><span style=3D"color:#66=
0">},</span><span style=3D"color:#000"> to </span><span style=3D"color:#660=
">{++</span><span style=3D"color:#000">finish</span><span style=3D"color:#6=
60">}</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{=
}</span><span style=3D"color:#000"><br><br><br>&nbsp; </span><span style=3D=
"color:#800">// usual constructors, assignments, typedefs, etc.</span><span=
 style=3D"color:#000"><br><br><br>&nbsp; </span><span style=3D"color:#008">=
inline</span><span style=3D"color:#000"> </span><span style=3D"color:#008">=
begin</span><span style=3D"color:#660">()</span><span style=3D"color:#000">=
 </span><span style=3D"color:#008">const</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">{</span><span style=3D"color:#008">return=
</span><span style=3D"color:#000"> </span><span style=3D"color:#008">from</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">}</span><span style=3D"color:#000"><br>&nbsp; </=
span><span style=3D"color:#008">inline</span><span style=3D"color:#000"> </=
span><span style=3D"color:#008">end</span><span style=3D"color:#660">()</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#008">const</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#008">return</span><span style=3D"color:#000"> to</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">}</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#660">};</span></div></code></div><div><br></div><div>This wou=
ld permit code like the following:</div><div><br></div><div style=3D"backgr=
ound-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:bre=
ak-word"><code><div><span style=3D"color:#008">for</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">(</span><span style=3D"color:#0=
08">auto</span><span style=3D"color:#000"> i </span><span style=3D"color:#6=
60">:</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">::</span><span style=3D"color:#000">range</span><span style=3D"color:#660=
">(</span><span style=3D"color:#066">0</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#066">7</span>=
<span style=3D"color:#660">))</span><span style=3D"color:#000"><br>&nbsp; <=
/span><span style=3D"color:#800">// ...</span></div></code></div><div><br><=
/div><div>Better still if there was a new operator .. introduced so that, f=
or example,</div><div><br></div><div style=3D"background-color:rgb(250,250,=
250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">for</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">(</span><span style=3D"color:#008">auto</span><span st=
yle=3D"color:#000"> i </span><span style=3D"color:#660">:</span><span style=
=3D"color:#000"> </span><span style=3D"color:#066">0</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">..</span><span style=3D"color=
:#000"> </span><span style=3D"color:#066">7</span><span style=3D"color:#660=
">)</span><span style=3D"color:#000"><br>&nbsp; </span><span style=3D"color=
:#800">// ...</span></div></code></div><div><br></div><div>would be syntact=
ic sugar for the above, but that's probably pushing things too much ;)</div=
></div></blockquote><div><br></div><div>Have you looked at the std::integer=
_sequence and std::make_index_sequence proposal?</div><div><br></div><div>h=
ttp://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3658.html<br></div>=
<div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&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_514_26395563.1401068720994--

.


Author: David Krauss <potswa@gmail.com>
Date: Mon, 26 May 2014 12:41:28 +0800
Raw View
--Apple-Mail=_5ABA32E5-5997-43EF-86A6-9BD781F06B27
Content-Type: text/plain; charset=ISO-8859-1


On 2014-05-26, at 9:45 AM, Greg Marr <gregmmarr@gmail.com> wrote:

> Have you looked at the std::integer_sequence and std::make_index_sequence proposal?
>
> http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3658.html

No, those are only for metaprogramming. Also, they are being standardized in C++14.

Boost already does have utilities like this: counting_range and irange. They are probably the best reference point for a proposal.

--

---
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=_5ABA32E5-5997-43EF-86A6-9BD781F06B27
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;05&ndash;26, at 9:45 AM, Greg Marr &lt;<a href=3D"mailto:gregmmarr@gm=
ail.com">gregmmarr@gmail.com</a>&gt; wrote:</div><br class=3D"Apple-interch=
ange-newline"><blockquote type=3D"cite"><div style=3D"font-family: Helvetic=
a; font-size: 12px; font-style: normal; font-variant: normal; font-weight: =
normal; letter-spacing: normal; line-height: normal; orphans: auto; text-al=
ign: start; text-indent: 0px; text-transform: none; white-space: normal; wi=
dows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir=3D=
"ltr"><div>Have you looked at the std::integer_sequence and std::make_index=
_sequence proposal?</div><div><br></div><div><a href=3D"http://www.open-std=
..org/JTC1/sc22/WG21/docs/papers/2013/n3658.html">http://www.open-std.org/JT=
C1/sc22/WG21/docs/papers/2013/n3658.html</a><br></div></div></div></blockqu=
ote><br></div><div>No, those are only for metaprogramming. Also, they are b=
eing standardized in C++14.</div><br><div>Boost already does have utilities=
 like this: <font face=3D"Courier">counting_range</font> and <font face=3D"=
Courier">irange</font>. They are probably the best reference point for a pr=
oposal.</div><div><br></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=_5ABA32E5-5997-43EF-86A6-9BD781F06B27--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Mon, 26 May 2014 13:50:19 -0400
Raw View
On 2014-05-24 16:09, Douglas Boffey wrote:
> [...]
> This would permit code like the following:
>=20
> for (auto i : std::range(0, 7))
>   // ...

This has come up before. IMHO what you really want is a class that
adheres to the usual container iteration (i.e. can be used in
range-based for, as above) with the following constructors:

index_range<T>(T upper_bound, options =3D half_open);
index_range<T>(T lower_bound, T upper_bound, options =3D half_open);
index_range<T>(T lower_bound, T upper_bound, T step,
               options =3D half_open);

....where options is an enum=C2=B9 with at least values half_open and closed=
..
(The other possible value is fully_open, though the value of that is
debatable.) Note that you cannot simply increment the upper bound, as
passing numeric_limits<T>::max() should work correctly. (A closed range
is useful for similar reasons.)

Note in particular the option to give only an upper bound (with an
implicit lower bound of 0... or more pedantically, T{}), which is what
is wanted a large percentage of the time.

(=C2=B9 A class enum would be preferred, but you also want to be able to na=
me
the values in the scope of index_range, which currently is awkward, at
best.)

> Better still if there was a new operator .. introduced so that, for examp=
le,
>=20
> for (auto i : 0 .. 7)
>   // ...

This is probably not going to happen :-).

--=20
Matthew

--=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: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 26 May 2014 11:59:22 -0700 (PDT)
Raw View
------=_Part_334_21407120.1401130762676
Content-Type: text/plain; charset=UTF-8



On Saturday, 24 May 2014 23:24:51 UTC+1, Mikhail Semenov wrote:
>
> Some time ago I experimented with such definitions. You can try and define
> even ranges with steps: range(100,2,-2).
> My opinion is that they are not as efficient as standard 'for' loops, but
> look good though.
>

The problem, as I see it, with including a step in the definition of range,
is that people would try something like the following:

for (auto i : range(1, 100, 2))
  // ...

which would produce an infinite loop.

I would have thought that with aggressive inlining, as I indicated in my
OP, a compiler should produce identical code???

--

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

<div dir=3D"ltr"><br><br>On Saturday, 24 May 2014 23:24:51 UTC+1, Mikhail S=
emenov  wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
><div>Some time ago I experimented with such definitions. You can try and d=
efine even ranges with steps: range(100,2,-2).<br></div><div>My opinion is =
that they are not as efficient as standard 'for' loops, but look good thoug=
h.</div></div></blockquote><div><br></div><div>The problem, as I see it, wi=
th including a step in the definition of range, is that people would try so=
mething like the following:</div><div><br></div><div class=3D"prettyprint" =
style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; backg=
round-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
for</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> i </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> range</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #066;" class=3D"styled-by-prettify">100</span><s=
pan 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=
: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">// ...</span></div></code></div><div><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0); background-color: rg=
b(250, 250, 250);"><br></span></div><div>which would produce an infinite lo=
op.</div><div><br></div><div>I would have thought that with aggressive inli=
ning, as I indicated in my OP, a compiler should produce identical code???<=
/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_334_21407120.1401130762676--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 26 May 2014 12:30:44 -0700 (PDT)
Raw View
------=_Part_2718_30102273.1401132644206
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Monday, 26 May 2014 18:50:47 UTC+1, Matthew Woehlke wrote:
>
> > Better still if there was a new operator .. introduced so that, for=20
> example,=20
> >=20
> > for (auto i : 0 .. 7)=20
> >   // ...=20
>
> This is probably not going to happen :-).=20
>

I fear you're right (hence the way I framed my comment), but I can dream=20
on=E2=80=A6=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_2718_30102273.1401132644206
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, 26 May 2014 18:50:47 UTC+1, Matthew Woe=
hlke  wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">&gt; Better still =
if there was a new operator .. introduced so that, for example,
<br>&gt;=20
<br>&gt; for (auto i : 0 .. 7)
<br>&gt; &nbsp; // ...
<br>
<br>This is probably not going to happen :-).
<br></blockquote><div><br></div><div>I fear you're right (hence the way I f=
ramed my comment), but I can dream on=E2=80=A6&nbsp;</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_2718_30102273.1401132644206--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Mon, 26 May 2014 15:33:10 -0400
Raw View
On 2014-05-26 14:59, Douglas Boffey wrote:
> On Saturday, 24 May 2014 23:24:51 UTC+1, Mikhail Semenov wrote:
>> Some time ago I experimented with such definitions. You can try and define
>> even ranges with steps: range(100,2,-2).
>> My opinion is that they are not as efficient as standard 'for' loops, but
>> look good though.
>>
>
> The problem, as I see it, with including a step in the definition of range,
> is that people would try something like the following:
>
> for (auto i : range(1, 100, 2))
>   // ...
>
> which would produce an infinite loop.

No; this is equivalent to 'for (auto i = 1; i < 100; i += 2)'. That is,
the range's end / operator++ shall be 'smart' enough to correctly
terminate when another iteration would exceed the "upper" boundary.
(Pedantically, in case of step < 0, the "upper" bound would be less than
the "lower" bound, hence the quotes.)

....though it's good to point this out.

--
Matthew

--

---
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 May 2014 00:37:27 -0700 (PDT)
Raw View
------=_Part_3115_15219890.1401176247563
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I have used this type of construct now for a while and it works very well.=
=20
However I think that the name std::range should be an overloaded function=
=20
rather than a class. This allows
more variants and also allows the type of the i to be adapted to the type=
=20
of the start and stop indices, such as:

static const double pi =3D 3.1416;
for (auto x : range(0.0, pi, pi / 4))
    // ...

My range function is for instance overloaded with a range(T*, size_t) to=20
iterate over a "pointer with count" type of simple data structure and also=
=20
range(T*) which iterates until the next element compares equal to T{} which=
=20
of course is intended for C strings.

This also interacts with modifiers like reversed, stepped, indexed, etc.=20
which are discussed in other proposals to improve the utility of range=20
based for. Note here that indexed solves the problem of getting both at=20
container elements and their indices quite elegantly:

for (auto& e : cont | indexed)
   e->setmyindex(e.index())

(Hm, I didn't implement "indexed" myself, so I'm speculating that=20
decltype(e) here must be some type of mediator with an operator-> to get at=
=20
the object, which is actually less appealing than it should).

Another minor comment would be that the end-test for the loop of a range()=
=20
with step would have to handle the sign of the step so that

for (int i : range(100, 0, -1))
   // ...

actually loops 100 times. It must also be defined how the end conditions=20
are handled in this case: will the loop run for the values 100 .. 0, 99 ..=
=20
0 or 100 .. 1? I think 99 .. 0 as it works for looping through a container=
=20
backwards using:

for (int i : range(cont.size(), 0, -1))
    cont[i].do_something();




Den m=C3=A5ndagen den 26:e maj 2014 kl. 21:33:26 UTC+2 skrev Matthew Woehlk=
e:
>
> On 2014-05-26 14:59, Douglas Boffey wrote:=20
> > On Saturday, 24 May 2014 23:24:51 UTC+1, Mikhail Semenov wrote:=20
> >> Some time ago I experimented with such definitions. You can try and=20
> define=20
> >> even ranges with steps: range(100,2,-2).=20
> >> My opinion is that they are not as efficient as standard 'for' loops,=
=20
> but=20
> >> look good though.=20
> >>=20
> >=20
> > The problem, as I see it, with including a step in the definition of=20
> range,=20
> > is that people would try something like the following:=20
> >=20
> > for (auto i : range(1, 100, 2))=20
> >   // ...=20
> >=20
> > which would produce an infinite loop.=20
>
> No; this is equivalent to 'for (auto i =3D 1; i < 100; i +=3D 2)'. That i=
s,=20
> the range's end / operator++ shall be 'smart' enough to correctly=20
> terminate when another iteration would exceed the "upper" boundary.=20
> (Pedantically, in case of step < 0, the "upper" bound would be less than=
=20
> the "lower" bound, hence the quotes.)=20
>
> ...though it's good to point this out.=20
>
> --=20
> Matthew=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_3115_15219890.1401176247563
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I have used this type of construct now for a while and it =
works very well. However I think that the name std::range should be an over=
loaded function rather than a class. This allows<div>more variants and also=
 allows the type of the i to be adapted to the type of the start and stop i=
ndices, such as:</div><div><br></div><div>static const double pi =3D 3.1416=
;</div><div>for (auto x : range(0.0, pi, pi / 4))</div><div>&nbsp; &nbsp; /=
/ ...</div><div><br></div><div>My range function is for instance overloaded=
 with a range(T*, size_t) to iterate over a "pointer with count" type of si=
mple data structure and also range(T*) which iterates until the next elemen=
t compares equal to T{} which of course is intended for C strings.</div><di=
v><br></div><div>This also interacts with modifiers like reversed, stepped,=
 indexed, etc. which are discussed in other proposals to improve the utilit=
y of range based for. Note here that indexed solves the problem of getting =
both at container elements and their indices quite elegantly:</div><div><br=
></div><div>for (auto&amp; e : cont | indexed)</div><div>&nbsp; &nbsp;e-&gt=
;setmyindex(e.index())</div><div><br></div><div>(Hm, I didn't implement "in=
dexed" myself, so I'm speculating that decltype(e) here must be some type o=
f mediator with an operator-&gt; to get at the object, which is actually le=
ss appealing than it should).</div><div><br></div><div>Another minor commen=
t would be that the end-test for the loop of a range() with step would have=
 to handle the sign of the step so that</div><div><br></div><div>for (int i=
 : range(100, 0, -1))</div><div>&nbsp; &nbsp;// ...</div><div><br></div><di=
v>actually loops 100 times. It must also be defined how the end conditions =
are handled in this case: will the loop run for the values 100 .. 0, 99 .. =
0 or 100 .. 1? I think 99 .. 0 as it works for looping through a container =
backwards using:</div><div><br></div><div>for (int i : range(cont.size(), 0=
, -1))</div><div>&nbsp; &nbsp; cont[i].do_something();</div><div><br></div>=
<div><br></div><div><br><br>Den m=C3=A5ndagen den 26:e maj 2014 kl. 21:33:2=
6 UTC+2 skrev Matthew Woehlke:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">=
On 2014-05-26 14:59, Douglas Boffey wrote:
<br>&gt; On Saturday, 24 May 2014 23:24:51 UTC+1, Mikhail Semenov wrote:
<br>&gt;&gt; Some time ago I experimented with such definitions. You can tr=
y and define=20
<br>&gt;&gt; even ranges with steps: range(100,2,-2).
<br>&gt;&gt; My opinion is that they are not as efficient as standard 'for'=
 loops, but=20
<br>&gt;&gt; look good though.
<br>&gt;&gt;
<br>&gt;=20
<br>&gt; The problem, as I see it, with including a step in the definition =
of range,=20
<br>&gt; is that people would try something like the following:
<br>&gt;=20
<br>&gt; for (auto i : range(1, 100, 2))
<br>&gt; &nbsp; // ...
<br>&gt;=20
<br>&gt; which would produce an infinite loop.
<br>
<br>No; this is equivalent to 'for (auto i =3D 1; i &lt; 100; i +=3D 2)'. T=
hat is,
<br>the range's end / operator++ shall be 'smart' enough to correctly
<br>terminate when another iteration would exceed the "upper" boundary.
<br>(Pedantically, in case of step &lt; 0, the "upper" bound would be less =
than
<br>the "lower" bound, hence the quotes.)
<br>
<br>...though it's good to point this out.
<br>
<br>--=20
<br>Matthew
<br>
<br></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_3115_15219890.1401176247563--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Tue, 27 May 2014 00:58:29 -0700 (PDT)
Raw View
------=_Part_13_20430432.1401177510125
Content-Type: text/plain; charset=UTF-8

The problem, as I see it, with including a step in the definition of range,
is that people would try something like the following:

for (auto i : range(1, 100, 2))
  // ...

which would produce an infinite loop.

I would have thought that with aggressive inlining, as I indicated in my
OP, a compiler should produce identical code???
Show trimmed content


No it won't if you implement it correctly.
The issue is that the implementation should probably define
range_up(1,100,2) and range_down(100,1,2). The issue here is that the step
should be probably unsigned int or int  where the the first two parameters
can be any enumeration:
range_up('a','z',2)

The implementation can correctly define that you pass the right bound.





--

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

<div dir=3D"ltr"><div style=3D"border: 1px solid rgb(187, 187, 187); word-w=
rap: break-word; background-color: rgb(250, 250, 250);"><code><div><span st=
yle=3D"color: rgb(0, 0, 136);"><div>The problem, as I see it, with includin=
g a step in the definition of range, is that people would try something lik=
e the following:</div><div><br></div><div style=3D"border: 1px solid rgb(18=
7, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"=
><code><div><span style=3D"color: rgb(0, 0, 136);">for</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">(</=
span><span style=3D"color: rgb(0, 0, 136);">auto</span><span style=3D"color=
: rgb(0, 0, 0);"> i </span><span style=3D"color: rgb(102, 102, 0);">:</span=
><span style=3D"color: rgb(0, 0, 0);"> range</span><span style=3D"color: rg=
b(102, 102, 0);">(</span><span style=3D"color: rgb(0, 102, 102);">1</span><=
span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0=
, 0, 0);"> </span><span style=3D"color: rgb(0, 102, 102);">100</span><span =
style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, =
0);"> </span><span style=3D"color: rgb(0, 102, 102);">2</span><span style=
=3D"color: rgb(102, 102, 0);">))</span><span style=3D"color: rgb(0, 0, 0);"=
><br>&nbsp; </span><span style=3D"color: rgb(136, 0, 0);">// ...</span></di=
v></code></div><div><span style=3D"color: rgb(102, 102, 0); background-colo=
r: rgb(250, 250, 250);"><br></span></div><div>which would produce an infini=
te loop.</div><div><br></div><div>I would have thought that with aggressive=
 inlining, as I indicated in my OP, a compiler should produce identical cod=
e???</div><a class=3D"gwt-Anchor" aria-hidden=3D"true" style=3D"display: no=
ne;">Show trimmed content</a> <div class=3D"GKA2MROCFFB" style=3D"display: =
none;"><div></div></div><div></div><div></div><div style=3D"display: none;"=
></div><div style=3D"display: none;"></div><div style=3D"display: none;"></=
div><div><div class=3D"GKA2MROCPYD"></div></div><div class=3D"GKA2MROCNCB">=
<div class=3D"GKA2MROCMCB GKA2MROCCGB"><div><div style=3D"display: inline-b=
lock;"><div style=3D"display: none;"></div></div> </div></div></div></span>=
</div></code><div>&nbsp;</div></div><div>&nbsp;</div><div>No it won't if yo=
u implement it correctly.</div><div>The issue is that the implementation sh=
ould probably define range_up(1,100,2) and range_down(100,1,2). The issue h=
ere is that the step should be probably unsigned int or&nbsp;int &nbsp;wher=
e the the first two parameters can be any enumeration:</div><div>range_up('=
a','z',2)</div><div>&nbsp;</div><div>The implementation can correctly defin=
e that you pass the&nbsp;right bound.</div><div>&nbsp;</div><div>&nbsp;</di=
v><div>&nbsp;</div><div>&nbsp;</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_13_20430432.1401177510125--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Tue, 27 May 2014 11:19:27 -0400
Raw View
On 2014-05-27 03:37, Bengt Gustafsson wrote:
> Another minor comment would be that the end-test for the loop of a range()
> with step would have to handle the sign of the step so that
>
> for (int i : range(100, 0, -1))
>    // ...
>
> actually loops 100 times. It must also be defined how the end conditions
> are handled in this case: will the loop run for the values 100 .. 0, 99 ..
> 0 or 100 .. 1? I think 99 .. 0 as it works for looping through a container
> backwards using:
>
> for (int i : range(cont.size(), 0, -1))
>     cont[i].do_something();

No; 'start' should be just that; the first value of the range. The above
should iterate over 100, 99, 98, ... 2, 1, i.e. [100, 0). If you want
(100, 0], use 'reversed(range(100))' :-). (Or add a range option for that.)

--
Matthew

--

---
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: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Tue, 27 May 2014 11:38:18 -0700 (PDT)
Raw View
------=_Part_3215_14677159.1401215898124
Content-Type: text/plain; charset=UTF-8

Here is a solution:

template<class T, class StepType = int>
struct range
{
    struct range_iterator
    {
        T i;
        StepType step;
        range_iterator(T a, StepType step1) :i(a), step(step1)
        {
            std::cout << "a:" << a << " step1: " << step1 << std::endl;
        }



        range_iterator& operator++()
        {
            i = static_cast<T>(i+step);
            return *this;
        }

        T operator*()
        {
            return i;
        }

        static friend bool operator==(const range_iterator& x, constrange_iterator
& y)
        {
            return (x.i == y.i);
        }

        static friend bool operator!=(const range_iterator& x,range_iterator
& y)
        {
            return x.i != y.i;
        }
    };

    range_iterator x;
    range_iterator finish;



    range(T i1, T stop1, StepType step = 1) :x(i1, step),
                                               finish((static_cast<StepType
>(stop1)-static_cast<StepType>(i1))*step < 0
                                               ? i1 : static_cast<T>(i1 + ((
static_cast<StepType>(stop1)-
       static_cast<StepType>(i1)) / step + 1)*step),
                                               step) {}

    range_iterator& begin() { return x; }
    range_iterator& end() { return finish; }
};





You can run:
for (unsigned x : range<unsigned>(10, 0, -3))
{
    std::cout << "range(10,0,-3):" << x << std::endl;
}


--

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

<div dir=3D"ltr"><div>Here is&nbsp;a solution:</div><div><br></div><div cla=
ss=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); border-im=
age: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 250);=
"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 0, 136);">template</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">class</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> T</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">,=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> <=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">c=
lass</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);=
"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 0, 10=
2);">StepType</span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">=3D</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 136);">int</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">&gt;</span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 136);">struct</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 0, 0);"> range<br></span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">struct</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> range_ite=
rator<br>&nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; T i</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &n=
bsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(0, 0, 0);"> step</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; range_iter=
ator</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102,=
 0);">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
0);">T a</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, =
102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0,=
 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 0, 102);">StepType</span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 0, 0);"> step1</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(102, 102, 0);">)</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">:</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);">i</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);">a</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">),</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 0);"> step</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 0);">step1</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">)</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbs=
p; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, =
0);">{</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">cout </span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;&lt;</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);">"a:"</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&=
lt;&lt;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
0);"> a </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, =
102, 0);">&lt;&lt;</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 136, 0);">" step1: "</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"> step1 </span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> std</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">endl</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; =
&nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(102, 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"><br><br><br><br>&nbsp; &nbsp; &nbsp; &nbsp; range_ite=
rator</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">&amp;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0,=
 0, 136);">operator</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">++()</span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; i </span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(102, 102, 0);">=3D</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 136);">static_cast</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 0);">T</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(102, 102, 0);">&gt;(</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">i</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">+</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">step</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">);</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 136);">return</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(102, 102, 0);">*</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(0, 0, 136);">this</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &n=
bsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; T </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 136);">operator</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(102, 102, 0);">*()</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &n=
bsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">return</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> i</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp=
; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">}</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">static</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">friend</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">boo=
l</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> =
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">=
operator</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, =
102, 0);">=3D=3D(</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 136);">const</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"> range_iterator</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">&amp;</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 0);"> x</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(102, 102, 0);">,</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 136);">const</span><span class=3D"styl=
ed-by-prettify" style=3D"color: rgb(0, 0, 0);"> range_iterator</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> y</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&=
nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">=
return</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);">x</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 1=
02, 0);">.</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);">i </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0);">=3D=3D</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 0);"> y</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 102, 0);">.</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);">i</span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(102, 102, 0);">);</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp=
; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 136);">static</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 136);">friend</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 136);">bool</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 136);">operator</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(102, 102, 0);">!=3D(</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 136);">const</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 0);"> range_iterator</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> x</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">,<=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> ra=
nge_iterator</span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">&amp;</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 0);"> y</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">)</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 136);">return</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 0, 0);"> x</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">.</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);">i </span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(102, 102, 0);">!=3D</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(0, 0, 0);"> y</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(102, 102, 0);">.</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);">i</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbs=
p; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, =
0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);"><br>&nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(102, 102, 0);">};</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp; range_iterator x</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp;=
 &nbsp; range_iterator finish</span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);"><br><br><br><br>&nbsp; &nbsp; range</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">T i1</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">,</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> T s=
top1</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102,=
 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 0,=
 102);">StepType</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 0);"> step </span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(102, 102, 0);">=3D</span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 102, 102);">1</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">)</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">:</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);">x</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);">i1</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">,</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"> step</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(102, 102, 0);">),</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;finish</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">((<=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">s=
tatic_cast</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0);">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">&gt;(</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);">stop1</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(102, 102, 0);">)-</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 136);">static_cast</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(102, 0, 102);">StepType</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&gt;=
(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">i=
1</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0)=
;">))*</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);">step </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102,=
 102, 0);">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 102, 102);">0</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(102, 102, 0);">?</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 0);"> i1 </span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(102, 102, 0);">:</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(0, 0, 136);">static_cast</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">T</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&gt;(</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">i1 </span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">+</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">((</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">st=
atic_cast</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102,=
 102, 0);">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(102, 102, 0);">&gt;(</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);">stop1</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">)-</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 0);"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);"=
>static_cast</span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">&lt;</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">&gt;(</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);">i1</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">))</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(102, 102, 0);">/</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(0, 0, 0);"> step </span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">+</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 102, 102);">1</span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(102, 102, 0);">)*</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">step</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">),</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp;step</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102,=
 102, 0);">)</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(10=
2, 102, 0);">{}</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"><br>&nbsp; &nbsp; <br>&nbsp; &nbsp; range_iterator</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">begin<=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>()</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"=
> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0=
);">{</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0)=
;"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136=
);">return</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);"> x</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0);">;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"><br>&nbsp; &nbsp; range_iterator</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 136);">end</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">return</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> finish</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><b=
r></span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0=
);">};</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);"><br><br><br><br><br></span></div></code></div><div><br></div><div>You c=
an run:</div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187,=
 187, 187); border-image: none; -ms-word-wrap: break-word; background-color=
: rgb(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">f=
or</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=
 </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0)=
;">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136=
);">unsigned</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> x </span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">:</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 0);"> range</span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 136, 0);">&lt;unsigned&gt;</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 102, 102);">10</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(102, 102, 0);">,</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(0, 102, 102);">0</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(102, 102, 0);">,</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(102, 102, 0);">-</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 102, 102);">3</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">))</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; =
&nbsp; std</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0);">::</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);">cout </span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(102, 102, 0);">&lt;&lt;</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 136, 0);">"range(10,0,-3):"</span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> x </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> std</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">endl=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"=
><br></span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);"><br></span></div></code></div><br><div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&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_3215_14677159.1401215898124--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Tue, 27 May 2014 11:45:06 -0700 (PDT)
Raw View
------=_Part_602_11399748.1401216306362
Content-Type: text/plain; charset=UTF-8

Slightly refined to correct for zero steps:
template<class T, class StepType = int>
struct range
{
    struct range_iterator
    {
        T i;
        StepType step;
        range_iterator(T a, StepType step1) :i(a), step(step1)
        {
        }
        range_iterator& operator++()
        {
            i = static_cast<T>(i+step);
            return *this;
        }
        T operator*()
        {
            return i;
        }
        static friend bool operator==(const range_iterator& x, constrange_iterator
& y)
        {
            return (x.i == y.i);
        }
        static friend bool operator!=(const range_iterator& x,range_iterator
& y)
        {
            return x.i != y.i;
        }
    };
    range_iterator x;
    range_iterator finish;

    range(T i1, T stop1, StepType step = 1) :x(i1, step),
                                               finish((static_cast<StepType
>(stop1)-static_cast<StepType>(i1))*step <= 0
                                               ? i1 : static_cast<T>(i1 + ((
static_cast<StepType>(stop1)-static_cast<StepType>(i1)) / step + 1)*step),
                                               step) {}

    range_iterator& begin() { return x; }
    range_iterator& end() { return finish; }
};

If you run:
    for (unsigned x : range<unsigned>(10, 1, 0))
    {
        std::cout << "range(10,1,0):" << x << std::endl;
    }


The body will not run: nothing will be printed.

--

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

<div dir=3D"ltr"><div>Slightly refined to correct for zero steps:</div><div=
 class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); borde=
r-image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 2=
50);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">template</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">clas=
s</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> =
T</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0)=
;">,</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);=
"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136)=
;">class</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 0=
, 102);">StepType</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(102, 102, 0);">=3D</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 0, 136);">int</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">&gt;</span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(0, 0, 0);"><br></span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 136);">struct</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"> range<br></span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">struct</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> range_=
iterator<br>&nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; T i</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp;=
 &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);"> step</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; range_i=
terator</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 1=
02, 0);">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);">T a</span><span class=3D"styled-by-prettify" style=3D"color: rgb(10=
2, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(0, 0, 0);"> step1</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">)</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">:</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);">i</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);">a</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">),</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"> step</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 0);">step1</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(102, 102, 0);">)</span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &n=
bsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &n=
bsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; range_iterator</span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">operator</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">++()</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&=
nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
i </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0=
);">=3D</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 1=
36);">static_cast</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(102, 102, 0);">&lt;</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(0, 0, 0);">T</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(102, 102, 0);">&gt;(</span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(0, 0, 0);">i</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">+</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);">step</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(102, 102, 0);">);</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 1=
36);">return</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(10=
2, 102, 0);">*</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 136);">this</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 102, 0);">;</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp=
; &nbsp; T </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0,=
 0, 136);">operator</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">*()</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 136);">return</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 0, 0);"> i</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">;</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nb=
sp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(0, 0, 136);">static</span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(0, 0, 136);">friend</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 136);">bool</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 136);">operator</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">=3D=3D(</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">const</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> range_iterator=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">&amp;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, =
0);"> x</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 1=
02, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 136);">const</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);"> range_iterator</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">&amp;</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);"> y</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(102, 102, 0);">)</span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</sp=
an><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(0, 0, 136);">return</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 0);">x</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(102, 102, 0);">.</span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(0, 0, 0);">i </span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(102, 102, 0);">=3D=3D</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> y</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">.</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">i</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">);</span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &n=
bsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(102, 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"s=
tyled-by-prettify" style=3D"color: rgb(0, 0, 136);">static</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">friend</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">bool</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">operator</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=
!=3D(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 13=
6);">const</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);"> range_iterator</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">&amp;</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(0, 0, 0);"> x</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">,</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);"> range_iterator</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> y</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &n=
bsp; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">return</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> x</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">.</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">i </span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">!=3D<=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> y<=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>.</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=
i</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0)=
;">;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);=
"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">}</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">};</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; ra=
nge_iterator x</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(102, 102, 0);">;</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"><br>&nbsp; &nbsp; range_iterator finish</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br><br>&nbsp; &nbsp=
; range</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 1=
02, 0);">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);">T i1</span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"> T stop1</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(102, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 0, 102);">StepType</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 0, 0);"> step </span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(102, 102, 0);">=3D</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(0, 102, 102);">1</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(102, 102, 0);">)</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">:</span><span class=3D"styl=
ed-by-prettify" style=3D"color: rgb(0, 0, 0);">x</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 0);">i1</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(102, 102, 0);">,</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> step</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">),</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp;finish</span><span class=3D"styled-by-prettify" style=3D"color: rgb(10=
2, 102, 0);">((</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 136);">static_cast</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(102, 102, 0);">&lt;</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 0, 102);">StepType</span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(102, 102, 0);">&gt;(</span><span class=3D"st=
yled-by-prettify" style=3D"color: rgb(0, 0, 0);">stop1</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)-</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">static_cast</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 0, 102);=
">StepType</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102=
, 102, 0);">&gt;(</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);">i1</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(102, 102, 0);">))*</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);">step </span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(102, 102, 0);">&lt;=3D</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(0, 102, 102);">0</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">?</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> i1 </span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">:</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><spa=
n class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">static_cast=
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">&lt;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0=
);">T</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">&gt;(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);">i1 </span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">+</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(102, 102, 0);">((</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 136);">static_cast</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(102, 102, 0);">&lt;</span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(102, 0, 102);">StepType</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">&gt;(</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 0, 0);">stop1</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)-</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">static_cast</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">&=
lt;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 0, 10=
2);">StepType</span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">&gt;(</span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 0, 0);">i1</span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(102, 102, 0);">))</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">/</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"> step </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">+</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(0, 102, 102);">1</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(102, 102, 0);">)*</span><span class=3D"styled-by-pr=
ettify" style=3D"color: rgb(0, 0, 0);">step</span><span class=3D"styled-by-=
prettify" style=3D"color: rgb(102, 102, 0);">),</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;step</spa=
n><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">)</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{=
}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><=
br>&nbsp; &nbsp; <br>&nbsp; &nbsp; range_iterator</span><span class=3D"styl=
ed-by-prettify" style=3D"color: rgb(102, 102, 0);">&amp;</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">begin</span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">()</span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">return</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> x</=
span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">=
;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> =
</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);=
">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"=
><br>&nbsp; &nbsp; range_iterator</span><span class=3D"styled-by-prettify" =
style=3D"color: rgb(102, 102, 0);">&amp;</span><span class=3D"styled-by-pre=
ttify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 136);">end</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(102, 102, 0);">()</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-b=
y-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"style=
d-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 136);">return</span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> finish</span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">}</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br></span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">};</span=
></div></code></div><div><br>If you run:</div><div class=3D"prettyprint" st=
yle=3D"border: 1px solid rgb(187, 187, 187); border-image: none; -ms-word-w=
rap: break-word; background-color: rgb(250, 250, 250);"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);">&nbsp; &nbsp; </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 136);">for</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(102, 102, 0);">(</span><span class=3D"styl=
ed-by-prettify" style=3D"color: rgb(0, 0, 136);">unsigned</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> x </span><span clas=
s=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">:</span><span c=
lass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> range</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(0, 136, 0);">&lt;unsign=
ed&gt;</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 10=
2, 0);">(</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 1=
02, 102);">10</span><span class=3D"styled-by-prettify" style=3D"color: rgb(=
102, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 102, 102);">1</span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(0, 102, 102);">0</span><span class=3D"styled-by-prettify" style=3D"c=
olor: rgb(102, 102, 0);">))</span><span class=3D"styled-by-prettify" style=
=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; &nbsp; &nbsp; &nbsp=
; std</span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102=
, 0);">::</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0=
, 0);">cout </span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">&lt;&lt;</span><span class=3D"styled-by-prettify" style=3D"co=
lor: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 136, 0);">"range(10,1,0):"</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span class=3D"styled-=
by-prettify" style=3D"color: rgb(0, 0, 0);"> x </span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> std</span><span cla=
ss=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">::</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">endl</span><sp=
an class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br>&nbsp=
; &nbsp; </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102,=
 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0=
, 0, 0);"> <br></span></div></code></div><br><div><br></div><div>The body w=
ill not run: nothing will be printed.<br></div><div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&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_602_11399748.1401216306362--

.


Author: Greg Marr <gregmmarr@gmail.com>
Date: Wed, 28 May 2014 10:16:57 -0700 (PDT)
Raw View
------=_Part_549_29008776.1401297417498
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Monday, May 26, 2014 12:41:34 AM UTC-4, David Krauss wrote:
>
>
> On 2014=E2=80=9305=E2=80=9326, at 9:45 AM, Greg Marr <greg...@gmail.com <=
javascript:>>=20
> wrote:
>
> Have you looked at the std::integer_sequence and std::make_index_sequence=
=20
> proposal?
>
> http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3658.html
>
>
> No, those are only for metaprogramming.
>

Ah, so there's only get<> style compile-time iteration, not iterators for=
=20
runtime iteration?  I missed that point.
=20

> Also, they are being standardized in C++14.
>

Yes, I just wasn't sure the best way to word that, so I left it out.

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

<div dir=3D"ltr">On Monday, May 26, 2014 12:41:34 AM UTC-4, David Krauss wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:br=
eak-word"><br><div><div>On 2014=E2=80=9305=E2=80=9326, at 9:45 AM, Greg Mar=
r &lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"eZ=
ect86pduMJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;">greg...@gmail.com</a>&gt; wrote=
:</div><br><blockquote type=3D"cite"><div style=3D"font-family:Helvetica;fo=
nt-size:12px;font-style:normal;font-variant:normal;font-weight:normal;lette=
r-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-t=
ransform:none;white-space:normal;word-spacing:0px"><div dir=3D"ltr"><div>Ha=
ve you looked at the std::integer_sequence and std::make_index_sequence pro=
posal?</div><div><br></div><div><a href=3D"http://www.open-std.org/JTC1/sc2=
2/WG21/docs/papers/2013/n3658.html" target=3D"_blank" onmousedown=3D"this.h=
ref=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2FJTC1%2=
Fsc22%2FWG21%2Fdocs%2Fpapers%2F2013%2Fn3658.html\46sa\75D\46sntz\0751\46usg=
\75AFQjCNHwSTT834g-1yo1ODSk3uOp_E-9_w';return true;" onclick=3D"this.href=
=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2FJTC1%2Fsc=
22%2FWG21%2Fdocs%2Fpapers%2F2013%2Fn3658.html\46sa\75D\46sntz\0751\46usg\75=
AFQjCNHwSTT834g-1yo1ODSk3uOp_E-9_w';return true;">http://www.open-std.org/J=
TC1/<wbr>sc22/WG21/docs/papers/2013/<wbr>n3658.html</a><br></div></div></di=
v></blockquote><br></div><div>No, those are only for metaprogramming.</div>=
</div></blockquote><div><br></div><div>Ah, so there's only get&lt;&gt; styl=
e compile-time iteration, not iterators for runtime iteration? &nbsp;I miss=
ed that point.</div><div>&nbsp;</div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
 1ex;"><div style=3D"word-wrap:break-word"><div> Also, they are being stand=
ardized in C++14.</div></div></blockquote><div><br></div><div>Yes, I just w=
asn't sure the best way to word that, so I left it out.</div><div><br></div=
></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&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_549_29008776.1401297417498--

.