Topic: Proposal: the range class template for stepping


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 14 Jun 2014 06:49:28 -0700 (PDT)
Raw View
------=_Part_4_15780734.1402753768802
Content-Type: multipart/alternative;
 boundary="----=_Part_5_12572761.1402753768802"

------=_Part_5_12572761.1402753768802
Content-Type: text/plain; charset=UTF-8

I have attached the file containing this 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/.

------=_Part_5_12572761.1402753768802
Content-Type: text/html; charset=UTF-8

<div dir="ltr">I have attached the file&nbsp;containing this proposal.</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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_5_12572761.1402753768802--
------=_Part_4_15780734.1402753768802
Content-Type: text/html; charset=ISO-8859-1; name=The_range_Template.htm
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=The_range_Template.htm
X-Attachment-Id: af94684d-5ef6-4804-8c27-132312e011f8
Content-ID: <af94684d-5ef6-4804-8c27-132312e011f8>

<html>

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dwindows-125=
2">
<meta name=3DGenerator content=3D"Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
=09{font-family:Wingdings;
=09panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
=09{font-family:SimSun;
=09panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
=09{font-family:"Cambria Math";
=09panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
=09{font-family:Cambria;
=09panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
=09{font-family:Calibri;
=09panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
=09{font-family:Verdana;
=09panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
=09{font-family:"Anonymous Pro";
=09panose-1:2 6 6 9 3 2 2 0 5 4;}
@font-face
=09{font-family:"Arial Black";
=09panose-1:2 11 10 4 2 1 2 2 2 4;}
@font-face
=09{font-family:LMRoman10-Regular;
=09panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
=09{font-family:Consolas;
=09panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
=09{font-family:"Segoe UI";
=09panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
=09{font-family:"\@SimSun";
=09panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
=09{margin-top:0cm;
=09margin-right:0cm;
=09margin-bottom:10.0pt;
=09margin-left:0cm;
=09line-height:115%;
=09font-size:12.0pt;
=09font-family:"Times New Roman","serif";
=09color:windowtext;}
h1
=09{mso-style-link:"Heading 1 Char";
=09margin-top:12.0pt;
=09margin-right:0cm;
=09margin-bottom:3.0pt;
=09margin-left:0cm;
=09line-height:115%;
=09page-break-after:avoid;
=09font-size:16.0pt;
=09font-family:"Times New Roman","serif";
=09color:windowtext;
=09font-weight:bold;}
h2
=09{mso-style-link:"Heading 2 Char";
=09margin-top:12.0pt;
=09margin-right:0cm;
=09margin-bottom:3.0pt;
=09margin-left:0cm;
=09line-height:115%;
=09page-break-after:avoid;
=09font-size:12.0pt;
=09font-family:"Verdana","sans-serif";
=09color:windowtext;
=09font-weight:bold;}
h3
=09{mso-style-link:"Heading 3 Char";
=09margin-top:12.0pt;
=09margin-right:0cm;
=09margin-bottom:3.0pt;
=09margin-left:0cm;
=09line-height:115%;
=09page-break-after:avoid;
=09font-size:13.0pt;
=09font-family:"Cambria","serif";
=09color:windowtext;
=09font-weight:bold;}
p.MsoToc1, li.MsoToc1, div.MsoToc1
=09{margin-top:0cm;
=09margin-right:0cm;
=09margin-bottom:10.0pt;
=09margin-left:0cm;
=09line-height:115%;
=09font-size:12.0pt;
=09font-family:"Times New Roman","serif";
=09color:windowtext;}
p.MsoToc3, li.MsoToc3, div.MsoToc3
=09{margin-top:0cm;
=09margin-right:0cm;
=09margin-bottom:10.0pt;
=09margin-left:24.0pt;
=09line-height:115%;
=09font-size:12.0pt;
=09font-family:"Times New Roman","serif";
=09color:windowtext;}
a:link, span.MsoHyperlink
=09{color:blue;
=09text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
=09{color:purple;
=09text-decoration:underline;}
strong
=09{font-family:"Courier New";}
p
=09{margin-right:0cm;
=09margin-left:0cm;
=09font-size:10.5pt;
=09font-family:"Segoe UI","sans-serif";
=09color:#111111;}
code
=09{font-family:Consolas;
=09color:#990000;}
pre
=09{mso-style-link:"HTML Preformatted Char";
=09margin:0cm;
=09margin-bottom:.0001pt;
=09background:#FBEDBB;
=09border:none;
=09padding:0cm;
=09font-size:9.0pt;
=09font-family:Consolas;
=09color:black;}
p.MsoQuote, li.MsoQuote, div.MsoQuote
=09{mso-style-link:"Quote Char";
=09margin:0cm;
=09margin-bottom:.0001pt;
=09line-height:115%;
=09font-size:12.0pt;
=09font-family:"Anonymous Pro";
=09color:black;
=09font-weight:bold;}
span.QuoteChar
=09{mso-style-name:"Quote Char";
=09mso-style-link:Quote;
=09font-family:"Anonymous Pro";
=09color:black;
=09font-weight:bold;}
span.Heading2Char
=09{mso-style-name:"Heading 2 Char";
=09mso-style-link:"Heading 2";
=09font-family:"Verdana","sans-serif";
=09font-weight:bold;}
span.Heading1Char
=09{mso-style-name:"Heading 1 Char";
=09mso-style-link:"Heading 1";
=09font-family:"Times New Roman","serif";
=09font-weight:bold;}
span.HTMLPreformattedChar
=09{mso-style-name:"HTML Preformatted Char";
=09mso-style-link:"HTML Preformatted";
=09font-family:Consolas;
=09color:black;
=09background:#FBEDBB;}
span.code-keyword1
=09{mso-style-name:code-keyword1;
=09color:blue;}
span.code-sdkkeyword1
=09{mso-style-name:code-sdkkeyword1;
=09color:#339999;}
span.code-digit1
=09{mso-style-name:code-digit1;
=09color:navy;}
span.Heading3Char
=09{mso-style-name:"Heading 3 Char";
=09mso-style-link:"Heading 3";
=09font-family:"Cambria","serif";
=09font-weight:bold;}
@page WordSection1
=09{size:841.9pt 595.3pt;
=09margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
=09{page:WordSection1;}
 /* List Definitions */
 ol
=09{margin-bottom:0cm;}
ul
=09{margin-bottom:0cm;}
-->
</style>

</head>

<body lang=3DEN-GB link=3Dblue vlink=3Dpurple>

<div class=3DWordSection1>

<h1><a name=3D"_Toc390519938"></a><a name=3D"_Toc390505895"></a><a
name=3D"_Toc390500064"></a><a name=3D"_Toc390462549"></a><a name=3D"_Toc390=
461604"></a><a
name=3D"_Toc390461553"><span style=3D'font-size:20.0pt;line-height:115%'>Th=
e </span></a><span
style=3D'font-size:20.0pt;line-height:115%;font-family:"Arial Black","sans-=
serif"'>range</span><span
style=3D'font-size:20.0pt;line-height:115%'> Class Template, which Enables =
to
Iterate Through a Range of Integral Values</span><span style=3D'font-size:2=
0.0pt;
line-height:115%'> with a Given Step</span></h1>

<p class=3DMsoNormal>ISO/IEC JTC1 SC22 WG21</p>

<p class=3DMsoNormal><i>Mikhail Semenov</i>, mikhail_semenov@hotmail.com</p=
>

<p class=3DMsoToc1><span class=3DMsoHyperlink><a href=3D"#_Toc390519939">In=
troduction</a></span></p>

<p class=3DMsoToc1><span class=3DMsoHyperlink><a href=3D"#_Toc390519940">Th=
e <span
style=3D'font-family:"Verdana","sans-serif"'>range</span> Class Template</a=
></span></p>

<p class=3DMsoToc1><span class=3DMsoHyperlink><a href=3D"#_Toc390519941">Im=
pact on
standard</a></span></p>

<p class=3DMsoToc1><span class=3DMsoHyperlink><a href=3D"#_Toc390519942">Im=
plementation</a></span></p>

<p class=3DMsoToc1><span class=3DMsoHyperlink><a href=3D"#_Toc390519943">Ef=
ficiency
Considerations</a></span></p>

<p class=3DMsoToc3 style=3D'margin-left:0cm'><span class=3DMsoHyperlink><a
href=3D"#_Toc390519944">References</a></span></p>

<h1><a name=3D"_Toc390519939"></a><a name=3D"_Toc390461554">Introduction</a=
></h1>

<p class=3DMsoNormal>In C++, traditional for-loops are not very convenient,
especially if we try to iterate through a range of unsigned values in
descending order. For example, in order to iterate from N-1 down to 0 using=
 the
unsigned type std::size_t we have to write something like that:</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>for
(std::size_t=A0 j =3D=A0 N;=A0 j-- !=3D 0;)</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0 . . .</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>}</sp=
an></b><span
style=3D'font-family:"Courier New"'>=A0 </span></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>&nbs=
p;</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>Anot=
her
issue is with full ranges. If we want to iterate through the whole range of
unsigned char, we will have to write something like this:</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>&nbsp=
;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>for
(unsigned char c =3D std::numeric_limits&lt;unsigned char&gt;::min(), stop =
=3D 0; </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0 stop
=3D=3D 0; </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0 (c =3D=3D
std::numeric_limits&lt;unsigned char&gt;::max() ? stop =3D 1 : c++))</span>=
</b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0 std::cout
&lt;&lt; static_cast&lt;unsigned&gt;(c) &lt;&lt; std::endl;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>}</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>&nbs=
p;</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>The =
right
bound in the range of the C++ for-loop is evaluated at every step.=A0 In or=
der to
make loops more efficient it is necessary to introduce extra variables:</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>&nbs=
p;</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>for (=
int i
=3D 0, finish =3D static_cast&lt;int&gt;(100.0 * sin(x)); i &lt;=3D finish;=
 ++i)</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0 . . .</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>}</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>&nbs=
p;</p>

<p class=3DMsoNormal>In other programming languages (like Python[<a href=3D=
"#Python">1</a>],
Pascal, etc) it is possible to use ranges with steps. =A0This proposal offe=
rs a
similar feature for C++.</p>

<h1><a name=3D"_Toc390519940"></a><a name=3D"_Toc390461555">The </a><span
style=3D'font-family:"Verdana","sans-serif"'>range</span> Class Template</h=
1>

<p class=3DMsoNormal>The proposal <b>range</b> template:</p>

<p class=3DMsoNormal>std::range&lt;T&gt;(T start, T finish, StepType step =
=3D 1)</p>

<p class=3DMsoNormal>The StepType can be one of the integral types and depe=
nds on
the type T, which can be an integral or enumeration type.</p>

<p class=3DMsoNormal>Both start and finish are included in the iteration (i=
n
contrast to Python). The reason is to be able to easily write loops for a d=
escending
range of unsigned values (like the one mentioned before):</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>for (=
auto=A0
j : std::range&lt;std::size_t&gt;(N-1, 0, -1))</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0 . . .</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>}</sp=
an></b></p>

<p class=3DMsoNormal>&nbsp;</p>

<p class=3DMsoNormal>The loop over the full range of <b>unsigned char</b> v=
alues
can be rewritten as follows:</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>for (=
auto c
=3D std::range&lt;unsigned::char&gt;(std::numeric_limits&lt;unsigned
char&gt;::min(), </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0=A0=A0=A0std::numeric_limits&lt;uns=
igned
char&gt;::max()))</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0 std::cout
&lt;&lt; static_cast&lt;unsigned&gt;(c) &lt;&lt; std::endl;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>}</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>&nbsp=
;</span></b></p>

<h1><a name=3D"_Toc390519941"></a><a name=3D"_Toc390461557"></a><a name=3Dc=
hanges>Impact
on standard</a></h1>

<p class=3DMsoNormal><span style=3D'color:black'>This is an addition to the=
 General
utilities library. </span></p>

<table class=3DMsoNormalTable border=3D1 cellspacing=3D0 cellpadding=3D0 wi=
dth=3D952
 style=3D'width:714.15pt;background:#CCFFCC;border-collapse:collapse;border=
:none'>
 <tr style=3D'height:77.75pt'>
  <td width=3D952 valign=3Dtop style=3D'width:714.15pt;border:solid windowt=
ext 1.0pt;
  padding:0cm 5.4pt 0cm 5.4pt;height:77.75pt'>
  <p class=3DMsoNormal><b><span style=3D'font-size:14.0pt;line-height:115%'=
>20.x
  Class template </span></b><b><span style=3D'line-height:115%;font-family:=
"Verdana","sans-serif"'>range</span></b></p>
  <p class=3DMsoNormal>The library provides a class template that can be us=
ed to
  iterate through integral or enumeration range of values in a for-loop:</p=
>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>tem=
plate&lt;class
  T&gt;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>cla=
ss
  range</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</=
span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>pub=
lic:</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt;tex=
t-indent:
  21.0pt'><b><span style=3D'font-size:11.0pt;line-height:115%;font-family:"=
Courier New"'>typedef
  </span></b><i><span style=3D'font-size:11.0pt;line-height:115%;font-famil=
y:
  "Courier New"'>unspecified</span></i><b><span style=3D'font-size:11.0pt;
  line-height:115%;font-family:"Courier New"'> step_type;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0 range(T
  left, T right, step_type step =3D
  1);=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 </span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0 </span></b><i><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>uns=
pecified</span></i><b><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>&am=
p;
  begin();</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><i=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0 unspecified</span></i><b><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>&am=
p;
  end()</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>};<=
/span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbs=
p;</span></b></p>
  <p class=3DMsoNormal>T shall be an integral or enumeration type.</p>
  <p class=3DMsoNormal>The following loop </p>
  <p class=3DMsoNormal><b><span style=3D'font-size:11.0pt;line-height:115%;
  font-family:"Courier New"'>for (auto <i>x</i>: std::range&lt;T&gt;(<i>exp=
r1</i>,
  <i>expr2</i>, <i>step</i>))</span></b></p>
  <p class=3DMsoNormal style=3D'text-indent:12.0pt'><b><i><span style=3D'fo=
nt-size:
  11.0pt;line-height:115%;font-family:"Courier New"'>statement</span></i></=
b><b><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>;</=
span></b></p>
  <p class=3DMsoNormal>is equivalent to this statement:</p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'>=
=A0=A0=A0=A0 <b><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>{</=
span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0
  typedef std::range&lt;T&gt;::step_type _steptype;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0
  _steptype _start =3D static_cast&lt;_steptype&gt;(<i>expr1</i>);</span></=
b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0
  _steptype _finish =3D static_cast&lt;_steptype&gt;(<i>expr2</i>);</span><=
/b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0
  _steptype _step =3D <i>step</i>;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0 if
  (_step &gt; 0)</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0 {</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
  for (_steptype _count =3D _start; _count &lt;=3D _finish; _count +=3D _st=
ep)</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
  {</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
  T=A0 <i>x</i> =3D static_cast&lt;T&gt;(_count);</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
  statement;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
  }</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0 }</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0
  else if (step &lt; 0)</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0
  {</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
  for (_steptype _count =3D _start; _count &gt;=3D _finish; _count +=3D _st=
ep)</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
  {</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
  T=A0 <i>x</i> =3D static_cast&lt;T&gt;(_count);</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0
  statement;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
  }</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:11.0pt;line-height:115%;font-family:"Courier New"'>=A0=
=A0=A0=A0=A0=A0 }</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt;tex=
t-indent:
  12.0pt'><b><span style=3D'font-size:11.0pt;line-height:115%;font-family:"=
Courier New"'>}</span></b><span
  style=3D'font-family:LMRoman10-Regular'> </span></p>
  <p class=3DMsoNormal style=3D'text-indent:12.0pt'><span style=3D'font-fam=
ily:LMRoman10-Regular'>[
  </span>Note: The body of the loop is not executed if the following is tru=
e: </p>
  <p class=3DMsoNormal style=3D'text-indent:12.0pt'><b><span style=3D'font-=
size:11.0pt;
  line-height:115%;font-family:"Courier New"'>(_step =3D=3D 0) || (sign(_st=
ep) *
  (_finish - _start) &lt; 0)</span></b> =97end note <span style=3D'font-fam=
ily:
  LMRoman10-Regular'>]</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b=
><span
  style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbs=
p;</span></b></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>[<i>Example:</i></span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>for (auto=A0 j : std::range&lt;std::size_t&gt;=
(3, 0,
  -1))</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>{</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>=A0=A0=A0 std::cout &lt;&lt; j &lt;&lt; std::e=
ndl;</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>}</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>This loop will output the following values:</s=
pan></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>3</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>2</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>1</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><s=
pan
  style=3D'line-height:115%'>0</span></p>
  <p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><e=
m><span
  style=3D'line-height:115%;color:black'>=97 end example</span></em><span
  style=3D'line-height:115%;color:black'> ]</span></p>
  </td>
 </tr>
</table>

<p class=3DMsoNormal>&nbsp;</p>

<h1><a name=3D"_Toc390519942"></a><a name=3D"_Toc390461556">Implementation<=
/a></h1>

<p class=3DMsoNormal>Here is a possible implementation of the <b>range</b> =
class template.</p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;class T&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct
range_step_type</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{</spa=
n></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
long int type; </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct
range_step_type&lt;int&gt; </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{=A0=
=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
std::conditional&lt;sizeof(long long int) =3D=3D sizeof(std::ptrdiff_t), lo=
ng long
int, long int&gt;::type type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct
range_step_type&lt;long&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{=A0=
=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
std::conditional&lt;sizeof(long long int) =3D=3D sizeof(std::ptrdiff_t), lo=
ng long
int, long int&gt;::type type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct
range_step_type&lt;unsigned&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{=A0=
=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
std::conditional&lt;sizeof(long long int) =3D=3D sizeof(std::ptrdiff_t), lo=
ng long
int, long int&gt;::type type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct=
 range_step_type&lt;long
unsigned&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{=A0=
=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
std::conditional&lt;sizeof(long long int) =3D=3D sizeof(std::ptrdiff_t), lo=
ng long
int, long int&gt;::type type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct
range_step_type&lt;long long int&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{</spa=
n></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
long long int type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te
&lt;&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>struct
range_step_type&lt;long long unsigned&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{</spa=
n></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
long long int type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>templa=
te&lt;class
T&gt;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>class =
range</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>{=A0=
=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>public=
:</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 typedef
typename range_step_type&lt;T&gt;::type step_type;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 class
range_iterator</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 {=A0=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0
step_type step;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0
step_type i;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 public:</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0 =A0=A0range_iterator(step_type
a, step_type step1) :i(a), step(step1) {}</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0
range_iterator&amp; operator++()</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0 {</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
i +=3D step;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
return *this;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0 }</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0 T
operator*() const</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0 {</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
return static_cast&lt;T&gt;(i);</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0 }</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0
operator step_type() const { return i; }=A0=A0=A0=A0=A0=A0=A0 </span></b></=
p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 };</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>privat=
e:</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0
range_iterator start;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0
range_iterator finish; </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 inline
static step_type finish_value(step_type left, step_type range, step_type st=
ep)</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 {=A0=A0=A0=A0=A0=A0=A0
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
 =A0=A0=A0=A0=A0if
(step =3D=3D 0) return left;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0
step_type ratio =3D (range=A0 + step)/ step;</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0 if
(ratio &gt;=3D 1) return left + ratio * step;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0
return left;=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 }</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>public=
:</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 range(T
left, T right, step_type step =3D 1) :</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
 =A0=A0=A0=A0=A0=A0=A0=A0=A0start(static_cast&lt;step_type&gt;(left),
step),</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0
finish(finish_value(static_cast&lt;step_type&gt;(left),static_cast&lt;step_=
type&gt;(right)-static_cast&lt;step_type&gt;(left),step),
step) {}=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 </span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>&nbsp;=
</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0 range_iterator&amp;
begin() { return start;=A0 }</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>=A0=A0=
=A0
range_iterator&amp; end()=A0=A0 { return finish; }</span></b></p>

<p class=3DMsoNormal style=3D'margin-bottom:0cm;margin-bottom:.0001pt'><b><=
span
style=3D'font-size:9.0pt;line-height:115%;font-family:"Courier New"'>};</sp=
an></b></p>

<p class=3DMsoNormal>&nbsp;</p>

<h1><a name=3D"_Toc390519943">Efficiency Considerations</a></h1>

<p class=3DMsoNormal>Some tests have been carried out on various compilers =
on 32-bit
and 64-bit code: they showed that the difference in timings between using
standard for-loops and the range template did not exceed 9% with an average=
 deviation
about 3% [<a href=3D"#Benchmark">2</a>].=A0 </p>

<h3><a name=3D"_Toc390519944">References</a></h3>

<p class=3DMsoNormal>[<a name=3DPython>1</a>]. Python 3.2 Build-in Function=
..: <a
href=3D"https://docs.python.org/3.2/library/functions.html">https://docs.py=
thon.org/3.2/library/functions.html</a></p>

<p class=3DMsoNormal>[<a name=3DBenchmark>2</a>]. Mikhail Semenov. <i>Imple=
mentation
of the Range Template: An Easy Way to Step Through a Range of Integral Valu=
es
in a For-Loop,</i></p>

<p class=3DMsoNormal>3 June 2014, <a
href=3D"http://www.codeproject.com/Articles/779839/Implementation-of-the-ra=
nge-Template-an-Easy-Way-t">http://www.codeproject.com/Articles/779839/Impl=
ementation-of-the-range-Template-an-Easy-Way-t</a></p>

<p class=3DMsoNormal>&nbsp;</p>

<p class=3DMsoNormal>&nbsp;</p>

<p class=3DMsoNormal>&nbsp;</p>

</div>

</body>

</html>

------=_Part_4_15780734.1402753768802--

.


Author: Philipp Maximilian Stephani <p.stephani2@gmail.com>
Date: Sat, 14 Jun 2014 19:33:32 +0000
Raw View
--001a11337e4293ca3404fbd0de3d
Content-Type: text/plain; charset=UTF-8

In general I think this is a very good idea.

I'd rename it to irange, this is what Boost.Range has. "range" is a very
generic term in C++ which is usually meant as anything that can be iterated
over, not only integral ranges.
I'd make it a function to make it unnecessary to specify the type.
I'd include the Python one-argument overload that sets the lower bound to
0. This might look weird as essentially the first parameter is then
optional (which is normally not possible in C++), but I think this case is
so common that it deserves a shorthand.
The range definitely needs to be half-open. (Like all other ranges in C++.)

On Sat Jun 14 2014 at 15:49:30, Mikhail Semenov <
mikhailsemenov1957@gmail.com> wrote:

> I have attached the file containing this 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/.
>

--

---
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/.

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

In general I think this is a very good idea.<br><div><br></div><div>I&#39;d=
 rename it to irange, this is what Boost.Range has. &quot;range&quot; is a =
very generic term in C++ which is usually meant as anything that can be ite=
rated over, not only integral ranges.</div>
<div>I&#39;d make it a function to make it unnecessary to specify the type.=
</div><div>I&#39;d include the Python one-argument overload that sets the l=
ower bound to 0. This might look weird as essentially the first parameter i=
s then optional (which is normally not possible in C++), but I think this c=
ase is so common that it deserves a shorthand.</div>
<div>The range definitely needs to be half-open. (Like all other ranges in =
C++.)</div><br><div>On Sat Jun 14 2014 at 15:49:30, Mikhail Semenov &lt;<a =
href=3D"mailto:mikhailsemenov1957@gmail.com">mikhailsemenov1957@gmail.com</=
a>&gt; wrote:</div>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">I have attached the file=C2=
=A0containing this proposal.</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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</blockquote>

<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 />

--001a11337e4293ca3404fbd0de3d--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sun, 15 Jun 2014 01:39:05 -0700 (PDT)
Raw View
------=_Part_477_6991044.1402821546001
Content-Type: text/plain; charset=UTF-8

>I'd rename it to irange, this is what Boost.Range has. "range" is a very
generic term in C++ which is usually meant as anything that can be iterated
over, not only integral ranges.

That is not a problem. I am open to suggestions.

>I'd make it a function to make it unnecessary to specify the type.
I though about it (something like the usual make_range), but  taking into
account that the bounds can be any expressions. I think it's better to
state what the type of the loop counter is going to be.

>I'd include the Python one-argument overload that sets the lower bound to
0. This might look weird as essentially the first parameter is then
optional (which is normally not possible in C++), but I think this case is
so common that it deserves a shorthand.
Here again, I am open to suggestions, but I think it is still better to
define both bounds.

>The range definitely needs to be half-open. (Like all other ranges in C++.)

This is a bad idea to have a half-open range. How will you deal with ranges
that are cover the max or min bound? It would be impossible
to write something like std::range<std::size_t>(N-1, 0, -1)  (or you would
have to resort to some weird way of writing it again).
The loops where the right bound is min are the main reason why it is worth
proposing ranges in the first place.

(From my experience, it was OK when we did not use extensively the unsigned
std::size_t. In the past we used int.)

Loops with open ranges exist in Python, but not in Lisp, Ada, Pascal or
Algol.

There is no harm writing std::range<std::size_t>(0,N-1), know that N-1 is
evaluated only once (unless it's in an inner loop).

OK. Another approach.

Are you suggesting that we should consider maybe
std::range<std::size_t>(N, 0, -1) => N-1, N-2, ..., 0
std::range<std::size_t>(0, N) => 0, 1, ..., N-1

But I think that looks really confusing, unless we want to define two
ranges:
std::step_down<std::size_t>(N) => N-1,N-2,..., 0
std::step_up<std::size_t>(N) => 0,1,...,N-1









The range definitely needs to be half-open. (Like all other ranges in C++.)
>
> On Sat Jun 14 2014 at 15:49:30, Mikhail Semenov <mikhailse...@gmail.com
> <javascript:>> wrote:
>
>> I have attached the file containing this 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>

--

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

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

<div dir=3D"ltr"><div><font color=3D"#9900ff">&gt;I'd rename it to irange, =
this is what Boost.Range has. "range" is a very generic term in C++ which i=
s usually meant as anything that can be iterated over, not only integral ra=
nges.</font></div><div><br></div><div>That is not a problem. I am open to s=
uggestions.</div><div><br></div><div><font color=3D"#9900ff">&gt;I'd make i=
t a function to make it unnecessary to specify the type.</font></div><div>I=
 though about it (something like the usual make_range), but&nbsp; taking in=
to account that the bounds can be any expressions. I think it's better to s=
tate what the type of the loop counter is going to be.</div><div><br></div>=
<div><font color=3D"#9900ff">&gt;I'd include the Python one-argument overlo=
ad that sets the lower bound to 0. This might look weird as essentially the=
 first parameter is then optional (which is normally not possible in C++), =
but I think this case is so common that it deserves a shorthand.</font></di=
v><div>Here again, I am open to suggestions, but I think it is still better=
 to define&nbsp;both bounds.</div><div><br></div><div><font color=3D"#9900f=
f">&gt;The range definitely needs to be half-open. (Like all other ranges i=
n C++.)</font></div><div><br></div><div>This is a bad idea to have a half-o=
pen range. How will you deal with ranges that are cover the max or min boun=
d? It would be impossible</div><div>to&nbsp;write something like std::range=
&lt;std::size_t&gt;(N-1, 0, -1)&nbsp; (or you would have to resort to some =
weird way of writing it again).&nbsp;</div><div>The loops&nbsp;where&nbsp;t=
he right bound&nbsp;is min&nbsp;are the main reason why it is worth proposi=
ng ranges in the first place.</div><div><br></div><div>(From my experience,=
 it was OK when we did not use extensively the unsigned std::size_t. In the=
 past we used int.)</div><div><br></div><div>Loops with open&nbsp;ranges ex=
ist in Python, but not in Lisp, Ada, Pascal or Algol.</div><div><br></div><=
div>There is no&nbsp;harm writing std::range&lt;std::size_t&gt;(0,N-1), kno=
w that N-1 is evaluated only once (unless it's in an inner loop).</div><div=
><font color=3D"#0000ff"><br></font></div><div><font color=3D"#0000ff">OK. =
Another approach.&nbsp; </font></div><div><font color=3D"#0000ff"><font col=
or=3D"#000000"><br></font></font></div><div><font color=3D"#0000ff"><font c=
olor=3D"#000000">Are you suggesting that we should consider maybe</font></f=
ont></div><div><font color=3D"#222222">std::range&lt;std::size_t&gt;(N, 0, =
-1)&nbsp;=3D&gt; N-1, N-2, ..., 0</font></div><div>std::range&lt;std::size_=
t&gt;(0, N) =3D&gt; 0, 1, ..., N-1 </div><div><br></div><div>But I think th=
at looks really confusing, unless we want to define two ranges:</div><div>s=
td::step_down&lt;std::size_t&gt;(N) =3D&gt; N-1,N-2,..., 0</div><div>std::s=
tep_up&lt;std::size_t&gt;(N) =3D&gt; 0,1,...,N-1</div><div><br></div><div><=
br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><=
br></div><div><br><br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, =
204); border-left-width: 1px; border-left-style: solid;"><div>The range def=
initely needs to be half-open. (Like all other ranges in C++.)</div><br><di=
v>On Sat Jun 14 2014 at 15:49:30, Mikhail Semenov &lt;<a onmousedown=3D"thi=
s.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';r=
eturn true;" href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=
=3D"Aj2D4vPDh7AJ">mikhailse...@gmail.com</a>&gt; wrote:</div>
<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; paddi=
ng-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px=
; border-left-style: solid;"><div dir=3D"ltr">I have attached the file&nbsp=
;containing this proposal.</div>

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"=
_blank" gdf-obfuscated-mailto=3D"Aj2D4vPDh7AJ">std-proposal...@<wbr>isocpp.=
org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D'javascr=
ipt:';return true;" onclick=3D"this.href=3D'javascript:';return true;" href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Aj2D4vPDh7AJ">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote>
</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_477_6991044.1402821546001--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sun, 15 Jun 2014 01:51:09 -0700 (PDT)
Raw View
------=_Part_499_19330310.1402822269264
Content-Type: text/plain; charset=UTF-8

 Maybe another argument against open ranges.

 It is impossible to cover the full range:
for (auto x: std::range<short>(std::numeric_limits<short>::min(),
std::numeric_limits<short>::max())
{
....
}


You want be able to cover the full enumeration range.

enum Count
{
   One,
   Two,
   Three
};

for (auto c: std::range<Count>(One, Three)
{
....
}

--

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

<div dir=3D"ltr"><div>&nbsp;Maybe another argument against open ranges.</di=
v><div><br></div><div>&nbsp;It is impossible to cover the full range:</div>=
<div>for (auto x: std::range&lt;short&gt;(std::numeric_limits&lt;short&gt;:=
:min(), std::numeric_limits&lt;short&gt;::max())</div><div>{</div><div>...<=
/div><div>}</div><div><br></div><div><br></div><div>You want be able to cov=
er the full enumeration range.</div><div><br></div><div>enum Count</div><di=
v>{</div><div>&nbsp;&nbsp; One,</div><div>&nbsp;&nbsp; Two,</div><div>&nbsp=
;&nbsp; Three</div><div>};</div><div><br></div><div><div>for (auto c: std::=
range&lt;Count&gt;(One, Three)</div><div>{</div><div>...</div><div>}</div><=
/div>
</div>

<p></p>

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

------=_Part_499_19330310.1402822269264--

.


Author: vadim.petrochenkov@gmail.com
Date: Sun, 15 Jun 2014 03:59:59 -0700 (PDT)
Raw View
------=_Part_845_6372677.1402829999492
Content-Type: text/plain; charset=UTF-8

>>The range definitely needs to be half-open. (Like all other ranges in
C++.)

Not all, numeric ranges in <random> are closed.
Walter E. Brown (?) explained this choice in detail, but I don't remember
where exactly.

On Saturday, June 14, 2014 11:33:34 PM UTC+4, Philipp Stephani wrote:
>
> In general I think this is a very good idea.
>
> I'd rename it to irange, this is what Boost.Range has. "range" is a very
> generic term in C++ which is usually meant as anything that can be iterated
> over, not only integral ranges.
> I'd make it a function to make it unnecessary to specify the type.
> I'd include the Python one-argument overload that sets the lower bound to
> 0. This might look weird as essentially the first parameter is then
> optional (which is normally not possible in C++), but I think this case is
> so common that it deserves a shorthand.
> The range definitely needs to be half-open. (Like all other ranges in C++.)
>
> On Sat Jun 14 2014 at 15:49:30, Mikhail Semenov <mikhailse...@gmail.com
> <javascript:>> wrote:
>
>> I have attached the file containing this 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>

--

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

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

<div dir=3D"ltr">&gt;&gt;The range definitely needs to be half-open. (Like =
all other ranges in C++.)<div><br></div><div>Not all, numeric ranges in &lt=
;random&gt; are closed.</div><div>Walter E. Brown (?) explained this choice=
 in detail, but I don't remember where exactly.</div><div><br></div>On Satu=
rday, June 14, 2014 11:33:34 PM UTC+4, Philipp Stephani wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;">In general I think this is a very good idea=
..<br><div><br></div><div>I'd rename it to irange, this is what Boost.Range =
has. "range" is a very generic term in C++ which is usually meant as anythi=
ng that can be iterated over, not only integral ranges.</div>
<div>I'd make it a function to make it unnecessary to specify the type.</di=
v><div>I'd include the Python one-argument overload that sets the lower bou=
nd to 0. This might look weird as essentially the first parameter is then o=
ptional (which is normally not possible in C++), but I think this case is s=
o common that it deserves a shorthand.</div>
<div>The range definitely needs to be half-open. (Like all other ranges in =
C++.)</div><br><div>On Sat Jun 14 2014 at 15:49:30, Mikhail Semenov &lt;<a =
href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Aj2D4vPDh7A=
J" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.h=
ref=3D'javascript:';return true;">mikhailse...@gmail.com</a>&gt; wrote:</di=
v>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">I have attached the file&nb=
sp;containing this proposal.</div>



-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
Aj2D4vPDh7AJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@isocpp.org</a>=
..<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"Aj2D4vPDh7AJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br=
>
</blockquote>
</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_845_6372677.1402829999492--

.


Author: David Krauss <potswa@gmail.com>
Date: Sun, 15 Jun 2014 19:07:21 +0800
Raw View
On 2014-06-15, at 6:59 PM, vadim.petrochenkov@gmail.com wrote:

> >>The range definitely needs to be half-open. (Like all other ranges in C++.)
>
> Not all, numeric ranges in <random> are closed.
> Walter E. Brown (?) explained this choice in detail, but I don't remember where exactly.

Probably because the numeric value of the supremum of a half-open range of floating-point values will depend on the type used to express the range. [0, 1) in floats has a different measure than [0, 1) in doubles.

This doesn't really have any bearing on anything you can iterate over.

Perhaps there's another reason, but I suspect this is it.

--

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

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sun, 15 Jun 2014 06:29:31 -0700 (PDT)
Raw View
------=_Part_520_8063126.1402838972148
Content-Type: text/plain; charset=UTF-8

(1)
 >Not all, numeric ranges in <random> are closed.
We don't want to iterate over a floating-point range. That mistake was made
some time ago in Algol.

(2)
Another approach could be...
We could define range like in std::string:
std::range<T>(a,number_of_element_covered, step)
which means: from a to a+N-1 with step
But the problem here is that in this case N should be probably of step_type
for two reason:
(1) so that you could cover a wider range std::range<char>(0,256);
(2) std::range<unsigned>(N-1,-N, -1), which means from N-1 down to 0.

Even if we would like to make the second parameter always non-negative as std::range<unsigned>(N-1,N,
-1), I don't think it looks better.

(3)
Any suggestions on another name for std::range?
I am not sure about std::irange.
What about:
std::step_loop
std::range_loop
std::steps ?




--

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

<div dir=3D"ltr"><div><font color=3D"#000000">(1)</font></div><div><font co=
lor=3D"#9900ff">&nbsp;&gt;Not all, numeric ranges in &lt;random&gt; are clo=
sed.</font></div><div><font color=3D"#000000">We don't want to iterate over=
 a floating-point range. That mistake was made some time ago in Algol.</fon=
t></div><div><font color=3D"#000000"><br></font></div><div><font color=3D"#=
000000">(2)</font></div><div><font color=3D"#0000ff">Another approach could=
 be...</font></div><div><font color=3D"#000000">We could define range like =
in std::string:</font></div><div><font color=3D"#000000">std::range&lt;T&gt=
;(a,number_of_element_covered, step)</font></div><div><font color=3D"#00000=
0">which means: from a to a+N-1 with step </font></div><div><font color=3D"=
#000000">But the problem here is that in this case N should be probably of =
step_type for two reason:</font></div><div><font color=3D"#000000">(1) so t=
hat you could cover a wider range std::range&lt;char&gt;(0,256);</font></di=
v><div><font color=3D"#000000">(2) </font><font color=3D"#000000">std::rang=
e&lt;unsigned&gt;(N-1,-N, -1), which means from N-1 down to 0. </font></div=
><div><font color=3D"#000000"><br></font></div><div><font color=3D"#000000"=
>Even if we would like to make the second parameter always non-negative as =
<font color=3D"#000000">std::range&lt;unsigned&gt;(N-1,N, -1)</font>, I don=
't think it looks better.</font></div><div><font color=3D"#000000"><br></fo=
nt></div><div><font color=3D"#000000">(3) </font></div><div><font color=3D"=
#000000">Any suggestions on another name for std::range?</font></div><div><=
font color=3D"#000000">I am not sure about std::irange.</font></div><div><f=
ont color=3D"#000000">What about:</font></div><div><font color=3D"#000000">=
std::step_loop</font></div><div><font color=3D"#000000">std::range_loop</fo=
nt></div><div><font color=3D"#000000">std::steps ?</font></div><div><font c=
olor=3D"#000000"><br></font></div><div><font color=3D"#000000"><br></font><=
/div><div><font color=3D"#000000"><br></font></div><div><font color=3D"#000=
000"><br></font></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_520_8063126.1402838972148--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sun, 15 Jun 2014 06:44:36 -0700 (PDT)
Raw View
------=_Part_86_14344003.1402839877039
Content-Type: text/plain; charset=UTF-8

About a floating-point range.

If we really want to deal with a floating-point range, it should be
something like this:
std::float_range<T>(T a,T b, integral_type N)

h = (b-a)/(N-1)
a, a+h, a+2h, ..., b (N steps)
N >= 2
(or maybe h = (b-a)/N; N>=1; N+1 steps in the loop)

It will work for both cases a =< b and a > b.
But I think that should be a different class template.

--

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

<div dir=3D"ltr"><div><font color=3D"#222222"><font color=3D"#0000ff">About=
 a floating-point range</font>.</font></div><div><br></div><div><font color=
=3D"#000000">If we really want to deal with a floating-point range, it shou=
ld be something like this:</font></div><div><font color=3D"#000000">std::fl=
oat_range&lt;T&gt;(T a,T b, integral_type N)</font></div><div><font color=
=3D"#000000"><br></font></div><div><font color=3D"#000000">h =3D (b-a)/(N-1=
)</font></div><div><font color=3D"#000000">a, a+h, a+2h, ..., b (N steps)</=
font></div><div><font color=3D"#000000">N &gt;=3D 2</font></div><div><font =
color=3D"#000000">(or maybe h =3D (b-a)/N; N&gt;=3D1; N+1&nbsp;steps in the=
 loop)</font></div><div><font color=3D"#000000"><br></font></div><div><font=
 color=3D"#000000">It will work for both cases a =3D&lt; b and a &gt; b.</f=
ont></div><div><font color=3D"#000000">But I think that should be a differe=
nt class template.</font></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_86_14344003.1402839877039--

.


Author: vadim.petrochenkov@gmail.com
Date: Sun, 15 Jun 2014 10:30:16 -0700 (PDT)
Raw View
------=_Part_620_27070876.1402853416773
Content-Type: text/plain; charset=UTF-8

I didn't mean anything floating-point.
Constructor of uniform_int_distribution takes a closed numeric range.
(But actually it turned out to be the only example of such range in the
library).

On Sunday, June 15, 2014 5:29:32 PM UTC+4, Mikhail Semenov wrote:
>
> (1)
>  >Not all, numeric ranges in <random> are closed.
> We don't want to iterate over a floating-point range. That mistake was
> made some time ago in Algol.
>
> (2)
> Another approach could be...
> We could define range like in std::string:
> std::range<T>(a,number_of_element_covered, step)
> which means: from a to a+N-1 with step
> But the problem here is that in this case N should be probably of
> step_type for two reason:
> (1) so that you could cover a wider range std::range<char>(0,256);
> (2) std::range<unsigned>(N-1,-N, -1), which means from N-1 down to 0.
>
> Even if we would like to make the second parameter always non-negative as std::range<unsigned>(N-1,N,
> -1), I don't think it looks better.
>
> (3)
> Any suggestions on another name for std::range?
> I am not sure about std::irange.
> What about:
> std::step_loop
> std::range_loop
> std::steps ?
>
>
>
>
>

--

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

<div dir=3D"ltr"><div>I didn't mean anything&nbsp;<font color=3D"#000000">f=
loating-point.</font></div><div>Constructor of uniform_int_distribution tak=
es a closed numeric range.<br></div><div>(But actually it turned out to be =
the only example of such range in the library).</div><div><br></div>On Sund=
ay, June 15, 2014 5:29:32 PM UTC+4, Mikhail Semenov wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><font color=3D"#000000">(=
1)</font></div><div><font color=3D"#9900ff">&nbsp;&gt;Not all, numeric rang=
es in &lt;random&gt; are closed.</font></div><div><font color=3D"#000000">W=
e don't want to iterate over a floating-point range. That mistake was made =
some time ago in Algol.</font></div><div><font color=3D"#000000"><br></font=
></div><div><font color=3D"#000000">(2)</font></div><div><font color=3D"#00=
00ff">Another approach could be...</font></div><div><font color=3D"#000000"=
>We could define range like in std::string:</font></div><div><font color=3D=
"#000000">std::range&lt;T&gt;(a,number_of_element_covered, step)</font></di=
v><div><font color=3D"#000000">which means: from a to a+N-1 with step </fon=
t></div><div><font color=3D"#000000">But the problem here is that in this c=
ase N should be probably of step_type for two reason:</font></div><div><fon=
t color=3D"#000000">(1) so that you could cover a wider range std::range&lt=
;char&gt;(0,256);</font></div><div><font color=3D"#000000">(2) </font><font=
 color=3D"#000000">std::range&lt;unsigned&gt;(N-1,-N, -1), which means from=
 N-1 down to 0. </font></div><div><font color=3D"#000000"><br></font></div>=
<div><font color=3D"#000000">Even if we would like to make the second param=
eter always non-negative as <font color=3D"#000000">std::range&lt;unsigned&=
gt;(N-1,N, -1)</font>, I don't think it looks better.</font></div><div><fon=
t color=3D"#000000"><br></font></div><div><font color=3D"#000000">(3) </fon=
t></div><div><font color=3D"#000000">Any suggestions on another name for st=
d::range?</font></div><div><font color=3D"#000000">I am not sure about std:=
:irange.</font></div><div><font color=3D"#000000">What about:</font></div><=
div><font color=3D"#000000">std::step_loop</font></div><div><font color=3D"=
#000000">std::range_loop</font></div><div><font color=3D"#000000">std::step=
s ?</font></div><div><font color=3D"#000000"><br></font></div><div><font co=
lor=3D"#000000"><br></font></div><div><font color=3D"#000000"><br></font></=
div><div><font color=3D"#000000"><br></font></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_620_27070876.1402853416773--

.


Author: Greg Marr <gregmmarr@gmail.com>
Date: Sun, 15 Jun 2014 16:47:10 -0700 (PDT)
Raw View
------=_Part_1116_1268354.1402876030273
Content-Type: text/plain; charset=UTF-8

On Sunday, June 15, 2014 4:39:06 AM UTC-4, Mikhail Semenov wrote:
>
> >The range definitely needs to be half-open. (Like all other ranges in
> C++.)
>
> This is a bad idea to have a half-open range. How will you deal with
> ranges that are cover the max or min bound? It would be impossible
> to write something like std::range<std::size_t>(N-1, 0, -1)  (or you would
> have to resort to some weird way of writing it again).
> The loops where the right bound is min are the main reason why it is worth
> proposing ranges in the first place.
>


> Maybe another argument against open ranges.
>


>  It is impossible to cover the full range:
>


> for (auto x: std::range<short>(std::numeric_limits<short>::min(),
> std::numeric_limits<short>::max())
>

With a closed range, it is impossible to cover empty ranges.  So, either
way, half open or closed, there are ranges you can't represent.  Given
that, isn't it better to be consistent with the rest of the library than
inconsistent?

--

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

<div dir=3D"ltr">On Sunday, June 15, 2014 4:39:06 AM UTC-4, Mikhail Semenov=
 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><=
span style=3D"color: rgb(153, 0, 255); font-size: 13px;">&gt;The range defi=
nitely needs to be half-open. (Like all other ranges in C++.)</span><br></d=
iv><div><br></div><div>This is a bad idea to have a half-open range. How wi=
ll you deal with ranges that are cover the max or min bound? It would be im=
possible</div><div>to&nbsp;write something like std::range&lt;std::size_t&g=
t;(N-1, 0, -1)&nbsp; (or you would have to resort to some weird way of writ=
ing it again).&nbsp;</div><div>The loops&nbsp;where&nbsp;the right bound&nb=
sp;is min&nbsp;are the main reason why it is worth proposing ranges in the =
first place.</div></div></blockquote><div>&nbsp;</div><blockquote class=3D"=
gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc so=
lid;padding-left: 1ex;"><div dir=3D"ltr"><div><span style=3D"font-size: 13p=
x;">Maybe another argument against open ranges.</span></div></div></blockqu=
ote><div><span style=3D"font-size: 13px;">&nbsp;</span><br></div><blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><span style=3D"fon=
t-size: 13px;">&nbsp;It is impossible to cover the full range:</span></div>=
</div></blockquote><div>&nbsp;</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div><span style=3D"font-size: 13px;">for (auto x: s=
td::range&lt;short&gt;(std::numeric_limits&lt;short&gt;::min(), std::numeri=
c_limits&lt;short&gt;::max())</span></div></div></blockquote><div><br></div=
><div>With a closed range, it is impossible to cover empty ranges. &nbsp;<s=
pan style=3D"font-size: 13px;">So, either way, half open or closed, there a=
re ranges you can't represent. &nbsp;Given that, isn't it better to be cons=
istent with the rest of the library than inconsistent?</span></div><div><sp=
an style=3D"font-size: 13px;"><br></span></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_1116_1268354.1402876030273--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Mon, 16 Jun 2014 00:55:18 -0700 (PDT)
Raw View
------=_Part_37_3789941.1402905318798
Content-Type: text/plain; charset=UTF-8




>With a closed range, it is impossible to cover empty ranges.  So, either
way, half open or closed, there are ranges you can't represent.  Given
that, isn't it better to be consistent with the rest of the library than
inconsistent?
Most of the open ranges in STL are dealing with iterators. There is no much
point in using open ranges for integral types. Besides, with open ranges
you'll lose many features that I've pointed above.




--

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

<div dir=3D"ltr"><p><br><font><font><font><font><font style=3D"background-c=
olor: rgb(255, 255, 255);"><font color=3D"#9900ff">&gt;With a closed range,=
 it is impossible to cover empty <font>ranges</font>. &nbsp;<span style=3D"=
font-size: 13px;">So, either way, half open or closed, there are ranges you=
 can't represent. &nbsp;Given that, isn't it better to be consistent with t=
he rest of the library than inconsistent?</span></font></font></font></font=
></font></font></p><div>Most of the open ranges in STL are dealing with ite=
rators. There is no much point in using open ranges for integral types. Bes=
ides, with open ranges you'll lose many features that I've pointed above.</=
div><div>&nbsp;</div><span style=3D"font-size: 13px;"><p>&nbsp;</p><div><br=
></div></span></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_37_3789941.1402905318798--

.


Author: Greg Marr <gregmmarr@gmail.com>
Date: Mon, 16 Jun 2014 07:18:11 -0700 (PDT)
Raw View
------=_Part_1568_27193253.1402928291784
Content-Type: text/plain; charset=UTF-8

On Monday, June 16, 2014 3:55:18 AM UTC-4, Mikhail Semenov wrote:
>
>
> >With a closed range, it is impossible to cover empty ranges.  So, either
> way, half open or closed, there are ranges you can't represent.  Given
> that, isn't it better to be consistent with the rest of the library than
> inconsistent?
> Most of the open ranges in STL are dealing with iterators. There is no
> much point in using open ranges for integral types. Besides, with open
> ranges you'll lose many features that I've pointed above.
>

Should this then not use a counted range instead of a [start, end] range?
 The recent discussion in the ranges SG has talked about including the
current [start, end), but also counted, delimited, and infinite ranges.

--

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

<div dir=3D"ltr">On Monday, June 16, 2014 3:55:18 AM UTC-4, Mikhail Semenov=
 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"><p><br=
><font><font><font><font><font style=3D"background-color:rgb(255,255,255)">=
<font color=3D"#9900ff">&gt;With a closed range, it is impossible to cover =
empty <font>ranges</font>. &nbsp;<span style=3D"font-size:13px">So, either =
way, half open or closed, there are ranges you can't represent. &nbsp;Given=
 that, isn't it better to be consistent with the rest of the library than i=
nconsistent?</span></font></font></font></font></font></font></p><div>Most =
of the open ranges in STL are dealing with iterators. There is no much poin=
t in using open ranges for integral types. Besides, with open ranges you'll=
 lose many features that I've pointed above.</div></div></blockquote><div>&=
nbsp;</div><div>Should this then not use a counted range instead of a [star=
t, end] range? &nbsp;The recent discussion in the ranges SG has talked abou=
t including the current [start, end), but also counted, delimited, and infi=
nite ranges.</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_1568_27193253.1402928291784--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Mon, 16 Jun 2014 07:38:56 -0700 (PDT)
Raw View
------=_Part_1622_202399.1402929536324
Content-Type: text/plain; charset=UTF-8

>Should this then not use a counted range instead of a [start, end] range?
 The recent discussion in the ranges SG has talked about including the
current [start, end), >but also counted, delimited, and infinite ranges.

Would it make easier to write the loops that I mentioned or does it involve
other areas?

--

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

<div dir=3D"ltr"><div><font color=3D"#9900ff">&gt;Should this then not use =
a counted range instead of a [start, end] range? &nbsp;The recent discussio=
n in the ranges SG has talked about including the current [start, end), &gt=
;but also counted, delimited, and infinite ranges.</font></div><div><br>Wou=
ld it make easier to write the loops that I mentioned or does it involve ot=
her areas?<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_1622_202399.1402929536324--

.


Author: David Krauss <potswa@gmail.com>
Date: Mon, 16 Jun 2014 23:06:54 +0800
Raw View
--Apple-Mail=_8712CA87-98A1-42CB-BB39-09C6CB2CCFA6
Content-Type: text/plain; charset=ISO-8859-1


On 2014-06-16, at 3:55 PM, Mikhail Semenov <mikhailsemenov1957@gmail.com> wrote:

>
> >With a closed range, it is impossible to cover empty ranges.  So, either way, half open or closed, there are ranges you can't represent.  Given that, isn't it better to be consistent with the rest of the library than inconsistent?
>
> Most of the open ranges in STL are dealing with iterators. There is no much point in using open ranges for integral types. Besides, with open ranges you'll lose many features that I've pointed above.

Integer ranges will be used to represent index ranges, which are functionally similar to iterators.

There's no way the community will accept any sort of range facility not supporting empty ranges. Fully closed sets don't.

--

---
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=_8712CA87-98A1-42CB-BB39-09C6CB2CCFA6
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"><meta http-equiv=3D"Content-Type" content=3D"text/html cha=
rset=3Dwindows-1252"><meta http-equiv=3D"Content-Type" content=3D"text/html=
 charset=3Dwindows-1252"><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;06&ndash;16, at 3:55 PM, Mikhail Semenov &lt;<a href=3D"m=
ailto:mikhailsemenov1957@gmail.com">mikhailsemenov1957@gmail.com</a>&gt; wr=
ote:</div><br class=3D"Apple-interchange-newline"><blockquote type=3D"cite"=
><div dir=3D"ltr"><p><br><font><font><font><font><font style=3D"background-=
color: rgb(255, 255, 255);"><font color=3D"#9900ff">&gt;With a closed range=
, it is impossible to cover empty <font>ranges</font>. &nbsp;<span style=3D=
"font-size: 13px;">So, either way, half open or closed, there are ranges yo=
u can't represent. &nbsp;Given that, isn't it better to be consistent with =
the rest of the library than inconsistent?</span></font></font></font></fon=
t></font></font></p><div>Most of the open ranges in STL are dealing with it=
erators. There is no much point in using open ranges for integral types. Be=
sides, with open ranges you'll lose many features that I've pointed above.<=
/div></div></blockquote><div><br></div><div>Integer ranges will be used to =
represent index ranges, which are functionally similar to iterators.</div><=
/div><div><br></div><div>There&rsquo;s no way the community will accept any=
 sort of range facility not supporting empty ranges. Fully closed sets don&=
rsquo;t.</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=_8712CA87-98A1-42CB-BB39-09C6CB2CCFA6--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Tue, 17 Jun 2014 00:56:53 -0700 (PDT)
Raw View
------=_Part_64_4404350.1402991813476
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable


>There=E2=80=99s no way the community will accept any sort of range facilit=
y not=20
supporting empty ranges. Fully closed sets don=E2=80=99t.
We don't have to call it a range though (we could call it steps(a,b,s);=20
step_loop, counting_loop, etc.). But there should be a clear facility to=20
iterate from A to B without using fancy techniques.
=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_64_4404350.1402991813476
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br><font color=3D"#9900ff">&gt;There=E2=80=99s no wa=
y the community will accept any sort of range facility not supporting empty=
 ranges. Fully closed sets don=E2=80=99t.<br></font><font color=3D"#000000"=
>We don't have to call it a range though (we could call it&nbsp;steps(a,b,s=
); step_loop, counting_loop, etc.). But there should be a clear facility to=
 iterate from A to B without using fancy techniques.</font></div><div><font=
 color=3D"#000000"></font>&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_64_4404350.1402991813476--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Tue, 17 Jun 2014 06:52:19 -0700 (PDT)
Raw View
------=_Part_339_33321939.1403013140118
Content-Type: text/plain; charset=UTF-8


>
> Although confining it to integral ranges sounds good, what if, for
> example, one wanted to use the mpz class in the gmp library?
>

--

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

------=_Part_339_33321939.1403013140118
Content-Type: text/html; charset=UTF-8

<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class=gmail_quote>
<DIV dir=ltr>Although confining it to integral ranges sounds good, what if, for example, one wanted to use the mpz class in the gmp library?</DIV></BLOCKQUOTE>

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

------=_Part_339_33321939.1403013140118--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Tue, 17 Jun 2014 07:28:33 -0700 (PDT)
Raw View
------=_Part_355_20185819.1403015313129
Content-Type: text/plain; charset=UTF-8

 >Although confining it to integral ranges sounds good, what if, for
example, one wanted to use the mpz class in the gmp library?
As, in general, with multiple-precision arithmetic, there are several
solutions here:
(1) not to do anything (just use integral ranges and convert, but probably
not the best solution);
(2) define proper interface for limits (and other functions), compatible
with other C++ limits, so that we could use them to implement std::range,
which allows
to use the user-defined class. I don' see any problem with that.

I am not talking about floating-point ranges here!
__________________________________________________________________________________________________________________________

But my concern is that looking at how ranges are developing we may end up
with the following interface for writing loops say from N-1 down to 0 with
step -3 as something like:
std::reverse_range(0,N,3)
or
std::range(N-1,std::limits<unsigned>::beyond_min(),-3);




--

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

<div dir=3D"ltr"><div><font color=3D"#9900ff">&nbsp;&gt;Although confining =
it to integral ranges sounds good, what if, for example, one wanted to use =
the mpz class in the gmp library?</font></div><div><font color=3D"#000000">=
As, in general, with multiple-precision arithmetic, there are several solut=
ions here:</font></div><div><font color=3D"#000000">(1) not to do anything =
(just use integral ranges and convert, but probably not the best solution);=
</font></div><div><font color=3D"#000000">(2) define proper interface for l=
imits (and other functions), compatible with other C++ limits, so that we c=
ould use them to implement std::range, which allows</font></div><div><font =
color=3D"#000000">to use the user-defined class. I don' see any problem wit=
h that.</font></div><div><font color=3D"#000000"></font>&nbsp;</div><div><f=
ont color=3D"#000000">I am not talking about floating-point ranges here!</f=
ont></div><div><font color=3D"#000000">____________________________________=
___________________________________________________________________________=
___________</font></div><div><font color=3D"#000000"></font>&nbsp;</div><di=
v><font color=3D"#000000">But my concern is that looking at how ranges are =
developing we may end up with the following interface for writing loops say=
 from N-1 down to 0 with step -3 as something like:</font></div><div><font =
color=3D"#000000">std::reverse_range(0,N,3)</font></div><div><font color=3D=
"#000000">or</font></div><div><font color=3D"#000000">std::range(N-1,std::l=
imits&lt;unsigned&gt;::beyond_min(),-3);</font></div><div>&nbsp;</div><div>=
<font color=3D"#000000"></font>&nbsp;</div><div><font color=3D"#000000"></f=
ont>&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_355_20185819.1403015313129--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 17 Jun 2014 16:42:38 +0800
Raw View
--Apple-Mail=_CF852EF4-E6D3-4090-B50E-5F987230061C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-06-17, at 3:56 PM, Mikhail Semenov <mikhailsemenov1957@gmail.com> w=
rote:

> >There's no way the community will accept any sort of range facility not =
supporting empty ranges. Fully closed sets don't.
> We don't have to call it a range though (we could call it steps(a,b,s); s=
tep_loop, counting_loop, etc.). But there should be a clear facility to ite=
rate from A to B without using fancy techniques.

It's not about nomenclature. For-loops are simply more popular than do-loop=
s. You can model at-least-once behavior by adding one to the upper bound of=
 a half-open range. But vice versa, attempting to subtract one from unsigne=
d zero produces integer underflow and disaster.

--=20

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

--Apple-Mail=_CF852EF4-E6D3-4090-B50E-5F987230061C
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"><meta http-equiv=3D"Content-Type" content=3D"text/html cha=
rset=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-n=
bsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2=
014&ndash;06&ndash;17, at 3:56 PM, Mikhail Semenov &lt;<a href=3D"mailto:mi=
khailsemenov1957@gmail.com">mikhailsemenov1957@gmail.com</a>&gt; wrote:</di=
v><br><blockquote type=3D"cite"><div dir=3D"ltr"><font color=3D"#9900ff">&g=
t;There&rsquo;s no way the community will accept any sort of range facility=
 not supporting empty ranges. Fully closed sets don&rsquo;t.<br></font><fon=
t>We don't have to call it a range though (we could call it&nbsp;steps(a,b,=
s); step_loop, counting_loop, etc.). But there should be a clear facility t=
o iterate from A to B without using fancy techniques.</font></div></blockqu=
ote><div><br></div><div>It&rsquo;s not about nomenclature. For-loops are si=
mply more popular than do-loops. You can model at-least-once behavior by ad=
ding one to the upper bound of a half-open range. But vice versa, attemptin=
g to subtract one from unsigned zero produces integer underflow and disaste=
r.</div></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=_CF852EF4-E6D3-4090-B50E-5F987230061C--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Tue, 24 Jun 2014 13:55:38 -0700 (PDT)
Raw View
------=_Part_486_27799838.1403643338708
Content-Type: text/plain; charset=UTF-8

Thank you for all your suggestions. Here is a revised proposal.
I have made several changes:

(1) the name is changed to std::steps<T>;
(2) the upper bound is always excluded;
(3) there is a function make_steps(a,b,step);
(4) there is a version make_steps(n), which will iterate over the range [0,
n-1];
(5) the type T can be any arithmetic type, including user-defined.


https://dl.dropboxusercontent.com/u/35715999/The_steps_Template.htm

--

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

<div dir=3D"ltr"><div>Thank you for all your suggestions. Here is a revised=
 proposal.</div><div>I have made several changes:</div><div><br></div><div>=
(1) the name is changed to std::steps&lt;T&gt;;</div><div>(2) the upper bou=
nd is always excluded;</div><div>(3) there is a function make_steps(a,b,ste=
p);</div><div>(4) there is a version make_steps(n), which will iterate over=
&nbsp;the&nbsp;range [0, n-1];</div><div>(5) the type T can be any arithmet=
ic type, including user-defined.</div><div><br></div><div><br></div><div><a=
 href=3D"https://dl.dropboxusercontent.com/u/35715999/The_steps_Template.ht=
m">https://dl.dropboxusercontent.com/u/35715999/The_steps_Template.htm</a>&=
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_486_27799838.1403643338708--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Thu, 26 Jun 2014 04:09:41 -0700 (PDT)
Raw View
------=_Part_25_17015011.1403780981896
Content-Type: text/plain; charset=UTF-8


On Saturday, 14 June 2014 14:49:29 UTC+1, Mikhail Semenov wrote:
>
> The upper bound in the range of the C++ for-loop is evaluated at every
> step. In order to make loops more efficient it is necessary to introduce
> extra variables. In other programming languages (like Python [*1*
> <https://dl.dropboxusercontent.com/u/35715999/The_steps_Template.htm#Python>],
> Pascal, etc) it is possible to use ranges with steps. This proposal offers
> a similar feature for C++. An alternative approach is described in [*2*
> <https://dl.dropboxusercontent.com/u/35715999/The_steps_Template.htm#Alternative>
> ].
>

On any half-decent modern-day compiler, so long as no variables are
affected by the loop, any subexpression within the second part would
be removed from the loop, giving identical code to the example given.

--

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

<div dir=3D"ltr"><br>On Saturday, 14 June 2014 14:49:29 UTC+1, Mikhail Seme=
nov  wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1e=
x; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-le=
ft-style: solid;" class=3D"gmail_quote"><div dir=3D"ltr"><p style=3D"margin=
-bottom: 0pt;" class=3D"MsoNormal">The upper bound in the range of=20
the C++ for-loop is evaluated at every step.  In order to make loops more=
=20
efficient it is necessary to introduce extra variables.<b><span style=3D'li=
ne-height: 115%; font-family: "Courier New"; font-size: 11pt;'>=20
</span></b>In other programming languages (like Python [<a href=3D"https://=
dl.dropboxusercontent.com/u/35715999/The_steps_Template.htm#Python"><u><fon=
t color=3D"#0000ff">1</font></u></a>], Pascal, etc) it is possible to use r=
anges with steps.=20
 This proposal offers a similar feature for C++.  An alternative approach i=
s=20
described in [<a href=3D"https://dl.dropboxusercontent.com/u/35715999/The_s=
teps_Template.htm#Alternative"><u><font color=3D"#0000ff">2</font></u></a>]=
..</p></div></blockquote><div>&nbsp;</div><div>On any half-decent modern-day=
 compiler, so long as no variables are affected by the loop, any subexpress=
ion within the second part would be&nbsp;removed from the loop,&nbsp;giving=
 identical code to the example given.&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_25_17015011.1403780981896--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Thu, 26 Jun 2014 05:24:03 -0700 (PDT)
Raw View
------=_Part_5710_7696121.1403785443148
Content-Type: text/plain; charset=UTF-8



On any half-decent modern-day compiler, so long as no variables are
affected by the loop, any subexpression within the second part would be
removed from the loop, giving identical code to the example given.

That's true unless you run the code in debug mode, which I often do --
running simulators. And I am probably not the only one. I wish my simulator
ran faster.  Optimization is a great thing, but people often forget that
most of the time we run our code in debug mode.

--

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

<blockquote style=3D"margin-right: 0px;" dir=3D"ltr"><div class=3D"prettypr=
int" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span class=3D"styled-by-prettify" style=3D"color: rg=
b(102, 0, 102);">On</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 0);"> any half</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);">decent modern</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);">day compiler</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);"> so </span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">long</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);">as</span><=
span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><s=
pan class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">no</span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> variable=
s are affected </span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 136);">by</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"> the loop</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);"> any subexpression within the second part would b=
e removed </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 136);">from</span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(0, 0, 0);"> the loop</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);"> giving identical code to the example given</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></spa=
n></div></code></div><br>That's true unless you run the code in debug mode,=
 which I often do -- running simulators. And I am probably not the only one=
.. I wish my simulator ran faster.&nbsp; Optimization is a great thing, but =
people often forget that most of the time we run our code in debug mode. </=
blockquote>

<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_5710_7696121.1403785443148--

.


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Sat, 28 Jun 2014 09:36:29 -0700 (PDT)
Raw View
------=_Part_1063_22931269.1403973389244
Content-Type: text/plain; charset=UTF-8

I have started a new branch "Generators of Number Sequences: the steps
class template".

--

---
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_1063_22931269.1403973389244
Content-Type: text/html; charset=UTF-8

<div dir="ltr">I have started a new branch "Generators of Number Sequences: the steps class template".<br></div>

<p></p>

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

------=_Part_1063_22931269.1403973389244--

.