Topic: Iterable enums


Author: joseph.bruni@gmail.com
Date: Tue, 10 Mar 2015 16:53:17 -0700 (PDT)
Raw View
------=_Part_5480_568380066.1426031597678
Content-Type: multipart/alternative;
 boundary="----=_Part_5481_756507406.1426031597678"

------=_Part_5481_756507406.1426031597678
Content-Type: text/plain; charset=UTF-8

A feature I would like to see in a future language is iterable enums.
Currently, regular C enums are glorified ints and can be advanced using ++.
This might not be correct since an enum might contain gaps in the sequence.
Enum classes completely prohibit arithmetic on its values. They must first
be cast to ints. This has the same issue as above.

Another solution is to place all the enum values into a vector<>. This
allows for iterating through all the values, handles gaps in the sequence.
The problem here is that I now have my enum values in two places: in the
actual enum definition and in the vector initialization. I need to keep
them in sync.

I would like to see something like Java's values() method on the enum that
returns an array (vector) of the enums values. Since all values are know at
compile time, this method could easily be constexpr.

enum class Colors{ red=1, green=5, blue=10 };

for (auto color : Colors.values) {

// do something with each value

}



--

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

<div dir=3D"ltr">A feature I would like to see in a future language is iter=
able enums. Currently, regular C enums are glorified ints and can be advanc=
ed using ++. This might not be correct since an enum might contain gaps in =
the sequence. Enum classes completely prohibit arithmetic on its values. Th=
ey must first be cast to ints. This has the same issue as above.<div><br></=
div><div>Another solution is to place all the enum values into a vector&lt;=
&gt;. This allows for iterating through all the values, handles gaps in the=
 sequence. The problem here is that I now have my enum values in two places=
: in the actual enum definition and in the vector initialization. I need to=
 keep them in sync.</div><div><br></div><div>I would like to see something =
like Java's values() method on the enum that returns an array (vector) of t=
he enums values. Since all values are know at compile time, this method cou=
ld easily be constexpr.</div><div><br></div><div><div class=3D"prettyprint"=
 style=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, =
187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">enum</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Colors</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> red</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">1</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> green</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=3D</span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> blue</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">10</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br></span><font color=3D"#666600"><span style=3D"color=
: #008;" class=3D"styled-by-prettify">for</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> color </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Colors</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">values</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span></font></div></code></div></div><blockquote =
style=3D"margin: 0 0 0 40px; border: none; padding: 0px;"><div class=3D"pre=
ttyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px solid =
rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><font color=3D"#666600"><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">// do something with each value</span></f=
ont></div></code></div></blockquote><div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 1=
87); word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><font color=3D"#666600"><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br><br></span></font></div></code></div><br><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_5481_756507406.1426031597678--
------=_Part_5480_568380066.1426031597678--

.


Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Tue, 10 Mar 2015 22:08:36 -0700 (PDT)
Raw View
------=_Part_102_935334595.1426050516863
Content-Type: multipart/alternative;
 boundary="----=_Part_103_588242125.1426050516863"

------=_Part_103_588242125.1426050516863
Content-Type: text/plain; charset=UTF-8

The work on compile-time reflection would (most very likely) take care of
this. See papers like N4113
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4113.pdf), among
others, for examples of the directions this might go.

On Tuesday, March 10, 2015 at 4:53:17 PM UTC-7, joseph...@gmail.com wrote:
>
> A feature I would like to see in a future language is iterable enums.
> Currently, regular C enums are glorified ints and can be advanced using ++.
> This might not be correct since an enum might contain gaps in the sequence.
> Enum classes completely prohibit arithmetic on its values. They must first
> be cast to ints. This has the same issue as above.
>
> Another solution is to place all the enum values into a vector<>. This
> allows for iterating through all the values, handles gaps in the sequence.
> The problem here is that I now have my enum values in two places: in the
> actual enum definition and in the vector initialization. I need to keep
> them in sync.
>
> I would like to see something like Java's values() method on the enum that
> returns an array (vector) of the enums values. Since all values are know at
> compile time, this method could easily be constexpr.
>
> enum class Colors{ red=1, green=5, blue=10 };
>
> for (auto color : Colors.values) {
>
> // do something with each value
>
> }
>
>
>
>

--

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

<div dir=3D"ltr">The work on compile-time reflection would (most very likel=
y) take care of this. See papers like N4113 (http://www.open-std.org/jtc1/s=
c22/wg21/docs/papers/2014/n4113.pdf), among others, for examples of the dir=
ections this might go.<br><br>On Tuesday, March 10, 2015 at 4:53:17 PM UTC-=
7, joseph...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div dir=3D"ltr">A feature I would like to see in a future language is itera=
ble enums. Currently, regular C enums are glorified ints and can be advance=
d using ++. This might not be correct since an enum might contain gaps in t=
he sequence. Enum classes completely prohibit arithmetic on its values. The=
y must first be cast to ints. This has the same issue as above.<div><br></d=
iv><div>Another solution is to place all the enum values into a vector&lt;&=
gt;. This allows for iterating through all the values, handles gaps in the =
sequence. The problem here is that I now have my enum values in two places:=
 in the actual enum definition and in the vector initialization. I need to =
keep them in sync.</div><div><br></div><div>I would like to see something l=
ike Java's values() method on the enum that returns an array (vector) of th=
e enums values. Since all values are know at compile time, this method coul=
d easily be constexpr.</div><div><br></div><div><div style=3D"background-co=
lor:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word=
"><code><div><span style=3D"color:#008">enum</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#008">class</span><span style=3D"color:#000=
"> </span><span style=3D"color:#606">Colors</span><span style=3D"color:#660=
">{</span><span style=3D"color:#000"> red</span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#066">1</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> green</span><span style=3D"color:#660">=3D=
</span><span style=3D"color:#066">5</span><span style=3D"color:#660">,</spa=
n><span style=3D"color:#000"> blue</span><span style=3D"color:#660">=3D</sp=
an><span style=3D"color:#066">10</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">};</span><span style=3D"color:#000"><br><br></spa=
n><font color=3D"#666600"><span style=3D"color:#008">for</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=3D"c=
olor:#008">auto</span><span style=3D"color:#000"> color </span><span style=
=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#606">Colors</span><span style=3D"color:#660">.</span><span style=3D"c=
olor:#000">values</span><span style=3D"color:#660">)</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"><br></span></font></div></code></div></div><blockquote style=3D"margi=
n:0 0 0 40px;border:none;padding:0px"><div style=3D"background-color:rgb(25=
0,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><d=
iv><font color=3D"#666600"><span style=3D"color:#800">// do something with =
each value</span></font></div></code></div></blockquote><div><div style=3D"=
background-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wr=
ap:break-word"><code><div><font color=3D"#666600"><span style=3D"color:#660=
">}</span><span style=3D"color:#000"><br><br></span></font></div></code></d=
iv><br><br></div></div></blockquote></div>

<p></p>

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

------=_Part_103_588242125.1426050516863--
------=_Part_102_935334595.1426050516863--

.


Author: joseph.bruni@gmail.com
Date: Wed, 11 Mar 2015 11:11:15 -0700 (PDT)
Raw View
------=_Part_4859_1586565317.1426097475056
Content-Type: multipart/alternative;
 boundary="----=_Part_4860_98838020.1426097475057"

------=_Part_4860_98838020.1426097475057
Content-Type: text/plain; charset=UTF-8

The reflection would provide the low-level plumbing, but I would like to
see something higher level. Reflection is great if you are writing a
debugger or some sort of tool.

The more I think about it, I would like to see something like a high-level
compiler function (cf. `sizeof`), that would return a
`std::initializer_list` literal containing only the name components of the
enumeration. Having to work through a reflection API just to get a list of
names from an enumeration is a bit much.

On Tuesday, March 10, 2015 at 10:08:37 PM UTC-7, Sean Middleditch wrote:
>
> The work on compile-time reflection would (most very likely) take care of
> this. See papers like N4113 (
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4113.pdf), among
> others, for examples of the directions this might go.
>
> On Tuesday, March 10, 2015 at 4:53:17 PM UTC-7, joseph...@gmail.com wrote:
>>
>> A feature I would like to see in a future language is iterable enums.
>> Currently, regular C enums are glorified ints and can be advanced using ++.
>> This might not be correct since an enum might contain gaps in the sequence.
>> Enum classes completely prohibit arithmetic on its values. They must first
>> be cast to ints. This has the same issue as above.
>>
>> Another solution is to place all the enum values into a vector<>. This
>> allows for iterating through all the values, handles gaps in the sequence.
>> The problem here is that I now have my enum values in two places: in the
>> actual enum definition and in the vector initialization. I need to keep
>> them in sync.
>>
>> I would like to see something like Java's values() method on the enum
>> that returns an array (vector) of the enums values. Since all values are
>> know at compile time, this method could easily be constexpr.
>>
>> enum class Colors{ red=1, green=5, blue=10 };
>>
>> for (auto color : Colors.values) {
>>
>> // do something with each value
>>
>> }
>>
>>
>>
>>

--

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

<div dir=3D"ltr">The reflection would provide the low-level plumbing, but I=
 would like to see something higher level. Reflection is great if you are w=
riting a debugger or some sort of tool.<div><br></div><div>The more I think=
 about it, I would like to see something like a high-level compiler functio=
n (cf. `sizeof`), that would return a `std::initializer_list` literal conta=
ining only the name components of the enumeration. Having to work through a=
 reflection API just to get a list of names from an enumeration is a bit mu=
ch.<br><br>On Tuesday, March 10, 2015 at 10:08:37 PM UTC-7, Sean Middleditc=
h 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">The w=
ork on compile-time reflection would (most very likely) take care of this. =
See papers like N4113 (<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/do=
cs/papers/2014/n4113.pdf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D=
"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2=
Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4113.pdf\46sa\75D\46sntz\0751=
\46usg\75AFQjCNEhUPqqDlydJZmiiz7s0pwD4EHQjg';return true;" onclick=3D"this.=
href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%=
2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4113.pdf\46sa\75D\46sntz\0751\46usg=
\75AFQjCNEhUPqqDlydJZmiiz7s0pwD4EHQjg';return true;">http://www.open-std.or=
g/jtc1/<wbr>sc22/wg21/docs/papers/2014/<wbr>n4113.pdf</a>), among others, f=
or examples of the directions this might go.<br><br>On Tuesday, March 10, 2=
015 at 4:53:17 PM UTC-7, <a>joseph...@gmail.com</a> wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">A feature I would like to see in a =
future language is iterable enums. Currently, regular C enums are glorified=
 ints and can be advanced using ++. This might not be correct since an enum=
 might contain gaps in the sequence. Enum classes completely prohibit arith=
metic on its values. They must first be cast to ints. This has the same iss=
ue as above.<div><br></div><div>Another solution is to place all the enum v=
alues into a vector&lt;&gt;. This allows for iterating through all the valu=
es, handles gaps in the sequence. The problem here is that I now have my en=
um values in two places: in the actual enum definition and in the vector in=
itialization. I need to keep them in sync.</div><div><br></div><div>I would=
 like to see something like Java's values() method on the enum that returns=
 an array (vector) of the enums values. Since all values are know at compil=
e time, this method could easily be constexpr.</div><div><br></div><div><di=
v style=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,187,1=
87);word-wrap:break-word"><code><div><span style=3D"color:#008">enum</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">class</span><=
span style=3D"color:#000"> </span><span style=3D"color:#606">Colors</span><=
span style=3D"color:#660">{</span><span style=3D"color:#000"> red</span><sp=
an style=3D"color:#660">=3D</span><span style=3D"color:#066">1</span><span =
style=3D"color:#660">,</span><span style=3D"color:#000"> green</span><span =
style=3D"color:#660">=3D</span><span style=3D"color:#066">5</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> blue</span><span styl=
e=3D"color:#660">=3D</span><span style=3D"color:#066">10</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">};</span><span style=3D"=
color:#000"><br><br></span><font color=3D"#666600"><span style=3D"color:#00=
8">for</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
(</span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> c=
olor </span><span style=3D"color:#660">:</span><span style=3D"color:#000"> =
</span><span style=3D"color:#606">Colors</span><span style=3D"color:#660">.=
</span><span style=3D"color:#000">values</span><span style=3D"color:#660">)=
</span><span style=3D"color:#000"> </span><span style=3D"color:#660">{</spa=
n><span style=3D"color:#000"><br></span></font></div></code></div></div><bl=
ockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><div style=3D"=
background-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wr=
ap:break-word"><code><div><font color=3D"#666600"><span style=3D"color:#800=
">// do something with each value</span></font></div></code></div></blockqu=
ote><div><div style=3D"background-color:rgb(250,250,250);border:1px solid r=
gb(187,187,187);word-wrap:break-word"><code><div><font color=3D"#666600"><s=
pan style=3D"color:#660">}</span><span style=3D"color:#000"><br><br></span>=
</font></div></code></div><br><br></div></div></blockquote></div></blockquo=
te></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_4860_98838020.1426097475057--
------=_Part_4859_1586565317.1426097475056--

.


Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Wed, 11 Mar 2015 18:16:48 +0000
Raw View
Are you wanting the names, as per the previous post, or the values, as
per the OP?

On 3/11/15, joseph.bruni@gmail.com <joseph.bruni@gmail.com> wrote:
> The reflection would provide the low-level plumbing, but I would like to
> see something higher level. Reflection is great if you are writing a
> debugger or some sort of tool.
>
> The more I think about it, I would like to see something like a high-level
> compiler function (cf. `sizeof`), that would return a
> `std::initializer_list` literal containing only the name components of the
> enumeration. Having to work through a reflection API just to get a list of
> names from an enumeration is a bit much.
>
> On Tuesday, March 10, 2015 at 10:08:37 PM UTC-7, Sean Middleditch wrote:
>>
>> The work on compile-time reflection would (most very likely) take care of
>>
>> this. See papers like N4113 (
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4113.pdf), among
>>
>> others, for examples of the directions this might go.
>>
>> On Tuesday, March 10, 2015 at 4:53:17 PM UTC-7, joseph...@gmail.com
>> wrote:
>>>
>>> A feature I would like to see in a future language is iterable enums.
>>> Currently, regular C enums are glorified ints and can be advanced using
>>> ++.
>>> This might not be correct since an enum might contain gaps in the
>>> sequence.
>>> Enum classes completely prohibit arithmetic on its values. They must
>>> first
>>> be cast to ints. This has the same issue as above.
>>>
>>> Another solution is to place all the enum values into a vector<>. This
>>> allows for iterating through all the values, handles gaps in the
>>> sequence.
>>> The problem here is that I now have my enum values in two places: in the
>>>
>>> actual enum definition and in the vector initialization. I need to keep
>>> them in sync.
>>>
>>> I would like to see something like Java's values() method on the enum
>>> that returns an array (vector) of the enums values. Since all values are
>>>
>>> know at compile time, this method could easily be constexpr.
>>>
>>> enum class Colors{ red=1, green=5, blue=10 };
>>>
>>> for (auto color : Colors.values) {
>>>
>>> // do something with each value
>>>
>>> }
>>>
>>>
>>>
>>>
>
> --
>
> ---
> 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/.

.


Author: joseph.bruni@gmail.com
Date: Wed, 11 Mar 2015 11:26:41 -0700 (PDT)
Raw View
------=_Part_7283_432770063.1426098401123
Content-Type: multipart/alternative;
 boundary="----=_Part_7284_39336452.1426098401123"

------=_Part_7284_39336452.1426098401123
Content-Type: text/plain; charset=UTF-8

Ultimately, the integer values. If the std::initializer_list literal
contained the names, the compiler would eventually resolve them to their
numeric values. These two for loops below should be equivalent assuming a
"std::values()" compiler function existed.

        enum small { zero, one, two, three };

for (auto a : { zero, one, two, three }) {
cout << a << '\n';
}
 for (auto a : std::values(small)) {
cout << a << '\n';
}




On Wednesday, March 11, 2015 at 11:16:50 AM UTC-7, Douglas Boffey wrote:
>
> Are you wanting the names, as per the previous post, or the values, as
> per the OP?
>
> On 3/11/15, joseph...@gmail.com <javascript:> <joseph...@gmail.com
> <javascript:>> wrote:
> > The reflection would provide the low-level plumbing, but I would like to
> > see something higher level. Reflection is great if you are writing a
> > debugger or some sort of tool.
> >
> > The more I think about it, I would like to see something like a
> high-level
> > compiler function (cf. `sizeof`), that would return a
> > `std::initializer_list` literal containing only the name components of
> the
> > enumeration. Having to work through a reflection API just to get a list
> of
> > names from an enumeration is a bit much.
> >
> > On Tuesday, March 10, 2015 at 10:08:37 PM UTC-7, Sean Middleditch wrote:
> >>
> >> The work on compile-time reflection would (most very likely) take care
> of
> >>
> >> this. See papers like N4113 (
> >> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4113.pdf),
> among
> >>
> >> others, for examples of the directions this might go.
> >>
> >> On Tuesday, March 10, 2015 at 4:53:17 PM UTC-7, joseph...@gmail.com
> >> wrote:
> >>>
> >>> A feature I would like to see in a future language is iterable enums.
> >>> Currently, regular C enums are glorified ints and can be advanced
> using
> >>> ++.
> >>> This might not be correct since an enum might contain gaps in the
> >>> sequence.
> >>> Enum classes completely prohibit arithmetic on its values. They must
> >>> first
> >>> be cast to ints. This has the same issue as above.
> >>>
> >>> Another solution is to place all the enum values into a vector<>. This
> >>> allows for iterating through all the values, handles gaps in the
> >>> sequence.
> >>> The problem here is that I now have my enum values in two places: in
> the
> >>>
> >>> actual enum definition and in the vector initialization. I need to
> keep
> >>> them in sync.
> >>>
> >>> I would like to see something like Java's values() method on the enum
> >>> that returns an array (vector) of the enums values. Since all values
> are
> >>>
> >>> know at compile time, this method could easily be constexpr.
> >>>
> >>> enum class Colors{ red=1, green=5, blue=10 };
> >>>
> >>> for (auto color : Colors.values) {
> >>>
> >>> // do something with each value
> >>>
> >>> }
> >>>
> >>>
> >>>
> >>>
> >
> > --
> >
> > ---
> > 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_7284_39336452.1426098401123
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Ultimately, the integer values. If the std::initializer_li=
st literal contained the names, the compiler would eventually resolve them =
to their numeric values. These two for loops below should be equivalent ass=
uming a "std::values()" compiler function existed.<div><br></div><div><div =
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border=
: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"font-family: Arial, H=
elvetica, sans-serif;"><span class=3D"Apple-tab-span" style=3D"white-space:=
pre"><span style=3D"color: #000;" class=3D"styled-by-prettify">&nbsp; &nbsp=
; &nbsp; &nbsp; </span></span><span style=3D"color: #008;" class=3D"styled-=
by-prettify">enum</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> small </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> zero=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> one</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> two</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> three </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">};</span></span></div></code><div class=3D"subprett=
yprint"><br></div><div class=3D"subprettyprint"><span class=3D"Apple-tab-sp=
an" style=3D"white-space:pre"> </span>for (auto a : { zero, one, two, three=
 }) {</div><div class=3D"subprettyprint"><span class=3D"Apple-tab-span" sty=
le=3D"white-space:pre">  </span>cout &lt;&lt; a &lt;&lt; '\n';</div><div cl=
ass=3D"subprettyprint"><span class=3D"Apple-tab-span" style=3D"white-space:=
pre"> </span>}</div><div class=3D"subprettyprint"><span class=3D"Apple-tab-=
span" style=3D"white-space:pre"> </span></div><div class=3D"subprettyprint"=
><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>for (auto=
 a : std::values(small)) {</div><div class=3D"subprettyprint"><span class=
=3D"Apple-tab-span" style=3D"white-space:pre">  </span>cout &lt;&lt; a &lt;=
&lt; '\n';</div><div class=3D"subprettyprint"><span class=3D"Apple-tab-span=
" style=3D"white-space:pre"> </span>}</div><div><br></div></div><br><br><br=
>On Wednesday, March 11, 2015 at 11:16:50 AM UTC-7, Douglas Boffey wrote:<b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;">Are you wanting the names, as pe=
r the previous post, or the values, as
<br>per the OP?
<br>
<br>On 3/11/15, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-ma=
ilto=3D"U2kG0SVYSNUJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascri=
pt:';return true;" onclick=3D"this.href=3D'javascript:';return true;">josep=
h...@gmail.com</a> &lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"U2kG0SVYSNUJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'j=
avascript:';return true;" onclick=3D"this.href=3D'javascript:';return true;=
">joseph...@gmail.com</a>&gt; wrote:
<br>&gt; The reflection would provide the low-level plumbing, but I would l=
ike to
<br>&gt; see something higher level. Reflection is great if you are writing=
 a
<br>&gt; debugger or some sort of tool.
<br>&gt;
<br>&gt; The more I think about it, I would like to see something like a hi=
gh-level
<br>&gt; compiler function (cf. `sizeof`), that would return a
<br>&gt; `std::initializer_list` literal containing only the name component=
s of the
<br>&gt; enumeration. Having to work through a reflection API just to get a=
 list of
<br>&gt; names from an enumeration is a bit much.
<br>&gt;
<br>&gt; On Tuesday, March 10, 2015 at 10:08:37 PM UTC-7, Sean Middleditch =
wrote:
<br>&gt;&gt;
<br>&gt;&gt; The work on compile-time reflection would (most very likely) t=
ake care of
<br>&gt;&gt;
<br>&gt;&gt; this. See papers like N4113 (
<br>&gt;&gt; <a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/=
2014/n4113.pdf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc=
22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4113.pdf\46sa\75D\46sntz\0751\46usg\75A=
FQjCNEhUPqqDlydJZmiiz7s0pwD4EHQjg';return true;" onclick=3D"this.href=3D'ht=
tp://www.google.com/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fw=
g21%2Fdocs%2Fpapers%2F2014%2Fn4113.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNE=
hUPqqDlydJZmiiz7s0pwD4EHQjg';return true;">http://www.open-std.org/jtc1/<wb=
r>sc22/wg21/docs/papers/2014/<wbr>n4113.pdf</a>), among
<br>&gt;&gt;
<br>&gt;&gt; others, for examples of the directions this might go.
<br>&gt;&gt;
<br>&gt;&gt; On Tuesday, March 10, 2015 at 4:53:17 PM UTC-7, <a>joseph...@g=
mail.com</a>
<br>&gt;&gt; wrote:
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; A feature I would like to see in a future language is iter=
able enums.
<br>&gt;&gt;&gt; Currently, regular C enums are glorified ints and can be a=
dvanced using
<br>&gt;&gt;&gt; ++.
<br>&gt;&gt;&gt; This might not be correct since an enum might contain gaps=
 in the
<br>&gt;&gt;&gt; sequence.
<br>&gt;&gt;&gt; Enum classes completely prohibit arithmetic on its values.=
 They must
<br>&gt;&gt;&gt; first
<br>&gt;&gt;&gt; be cast to ints. This has the same issue as above.
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; Another solution is to place all the enum values into a ve=
ctor&lt;&gt;. This
<br>&gt;&gt;&gt; allows for iterating through all the values, handles gaps =
in the
<br>&gt;&gt;&gt; sequence.
<br>&gt;&gt;&gt; The problem here is that I now have my enum values in two =
places: in the
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; actual enum definition and in the vector initialization. I=
 need to keep
<br>&gt;&gt;&gt; them in sync.
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; I would like to see something like Java's values() method =
on the enum
<br>&gt;&gt;&gt; that returns an array (vector) of the enums values. Since =
all values are
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; know at compile time, this method could easily be constexp=
r.
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; enum class Colors{ red=3D1, green=3D5, blue=3D10 };
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; for (auto color : Colors.values) {
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; // do something with each value
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; }
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt;
<br>&gt;
<br>&gt; --
<br>&gt;
<br>&gt; ---
<br>&gt; You received this message because you are subscribed to the Google=
 Groups
<br>&gt; "ISO C++ Standard - Future Proposals" group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, =
send an
<br>&gt; email to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"U2kG0SVYSNUJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javasc=
ript:';return true;" onclick=3D"this.href=3D'javascript:';return true;">std=
-proposal...@<wbr>isocpp.org</a>.
<br>&gt; To post to this group, send email to <a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"U2kG0SVYSNUJ" rel=3D"nofollow" onmous=
edown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'ja=
vascript:';return true;">std-pr...@isocpp.org</a>.
<br>&gt; Visit this group at
<br>&gt; <a href=3D"http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://=
groups.google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=
=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/=
';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>p=
roposals/</a>.
<br>&gt;
<br></blockquote></div></div>

<p></p>

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

------=_Part_7284_39336452.1426098401123--
------=_Part_7283_432770063.1426098401123--

.


Author: inkwizytoryankes@gmail.com
Date: Wed, 11 Mar 2015 12:41:39 -0700 (PDT)
Raw View
------=_Part_4605_1225137768.1426102899343
Content-Type: multipart/alternative;
 boundary="----=_Part_4606_817259340.1426102899343"

------=_Part_4606_817259340.1426102899343
Content-Type: text/plain; charset=UTF-8

You get reflection wrong, Its exactly tool you need to solve your problem.
Only thing its lack is function that will hide all dirty parts. It can be
provide by std, boost or written by yourself.
Fast implementation:
template<typename T1, typename T2>
struct list_helper;

template<typename T, size_t...I>
struct list_helper<T, std::integer_sequence<size_t, I...>>
{
    static std::vector<T> func() { return { reflection::enum_value<T,
I>()... }; }
}

template<typename T>
std::vector<T> values() { return list_helper<T, std::make_integer_sequence<size_t,
reflection::enum_size<T>()>>::func(); }
This should be change depending on your needs and environment, but overall
it be enough.


On Wednesday, March 11, 2015 at 7:11:15 PM UTC+1, joseph...@gmail.com wrote:
>
> The reflection would provide the low-level plumbing, but I would like to
> see something higher level. Reflection is great if you are writing a
> debugger or some sort of tool.
>
> The more I think about it, I would like to see something like a high-level
> compiler function (cf. `sizeof`), that would return a
> `std::initializer_list` literal containing only the name components of the
> enumeration. Having to work through a reflection API just to get a list of
> names from an enumeration is a bit much.
>
> On Tuesday, March 10, 2015 at 10:08:37 PM UTC-7, Sean Middleditch wrote:
>>
>> The work on compile-time reflection would (most very likely) take care of
>> this. See papers like N4113 (
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4113.pdf),
>> among others, for examples of the directions this might go.
>>
>> On Tuesday, March 10, 2015 at 4:53:17 PM UTC-7, joseph...@gmail.com
>> wrote:
>>>
>>> A feature I would like to see in a future language is iterable enums.
>>> Currently, regular C enums are glorified ints and can be advanced using ++.
>>> This might not be correct since an enum might contain gaps in the sequence.
>>> Enum classes completely prohibit arithmetic on its values. They must first
>>> be cast to ints. This has the same issue as above.
>>>
>>> Another solution is to place all the enum values into a vector<>. This
>>> allows for iterating through all the values, handles gaps in the sequence.
>>> The problem here is that I now have my enum values in two places: in the
>>> actual enum definition and in the vector initialization. I need to keep
>>> them in sync.
>>>
>>> I would like to see something like Java's values() method on the enum
>>> that returns an array (vector) of the enums values. Since all values are
>>> know at compile time, this method could easily be constexpr.
>>>
>>> enum class Colors{ red=1, green=5, blue=10 };
>>>
>>> for (auto color : Colors.values) {
>>>
>>> // do something with each value
>>>
>>> }
>>>
>>>
>>>
>>>

--

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

<div dir=3D"ltr">You get reflection wrong, Its exactly tool you need to sol=
ve your problem. Only thing its lack is function that will hide all dirty p=
arts. It can be provide by std, boost or written by yourself.<br>Fast imple=
mentation:<br><div class=3D"prettyprint" style=3D"background-color: rgb(250=
, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-=
width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y"><code class=3D"prettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">template&lt;typename T1, typename T2&gt;<br>struct </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify"><code class=3D"prett=
yprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">list_help=
er;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><br><br=
></span></code></span></code>template&lt;typename T, size_t...I&gt;<br>stru=
ct </span><span style=3D"color: #008;" class=3D"styled-by-prettify"><code c=
lass=3D"prettyprint"><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">list_helper</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"></span></code>&lt;T, </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify"><span class=3D"mw-geshi cpp source-cpp">std<span class=3D"s=
y4">::</span><span class=3D"me2">integer_sequence&lt;size_t, I...&gt;</span=
></span>&gt;<br>{<br>&nbsp;&nbsp;&nbsp; static std::vector&lt;T&gt; func() =
{ return { reflection::enum_value&lt;T, I&gt;()... }; }<br>}<br><br>templat=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">vector</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span>values<span style=3D"color: #660;" class=3D"styled-by-pret=
tify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> list_helper</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><code class=3D"prettyprint"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::make_integer_sequence</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;size_t, reflection::enum_size&lt;T&gt;(=
)&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"></spa=
n></code>&gt;::func();</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span></div></code></div>This should be change depending on your needs and e=
nvironment, but overall it be enough.<br><br><br>On Wednesday, March 11, 20=
15 at 7:11:15 PM UTC+1, joseph...@gmail.com wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;"><div dir=3D"ltr">The reflection would provide the low-l=
evel plumbing, but I would like to see something higher level. Reflection i=
s great if you are writing a debugger or some sort of tool.<div><br></div><=
div>The more I think about it, I would like to see something like a high-le=
vel compiler function (cf. `sizeof`), that would return a `std::initializer=
_list` literal containing only the name components of the enumeration. Havi=
ng to work through a reflection API just to get a list of names from an enu=
meration is a bit much.<br><br>On Tuesday, March 10, 2015 at 10:08:37 PM UT=
C-7, Sean Middleditch wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div di=
r=3D"ltr">The work on compile-time reflection would (most very likely) take=
 care of this. See papers like N4113 (<a href=3D"http://www.open-std.org/jt=
c1/sc22/wg21/docs/papers/2014/n4113.pdf" rel=3D"nofollow" target=3D"_blank"=
 onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4113.pdf\46sa\=
75D\46sntz\0751\46usg\75AFQjCNEhUPqqDlydJZmiiz7s0pwD4EHQjg';return true;" o=
nclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwww.open-=
std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2014%2Fn4113.pdf\46sa\75D\46=
sntz\0751\46usg\75AFQjCNEhUPqqDlydJZmiiz7s0pwD4EHQjg';return true;">http://=
www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2014/<wbr>n4113.pdf</a>), =
among others, for examples of the directions this might go.<br><br>On Tuesd=
ay, March 10, 2015 at 4:53:17 PM UTC-7, <a>joseph...@gmail.com</a> wrote:<b=
lockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">A feature I would li=
ke to see in a future language is iterable enums. Currently, regular C enum=
s are glorified ints and can be advanced using ++. This might not be correc=
t since an enum might contain gaps in the sequence. Enum classes completely=
 prohibit arithmetic on its values. They must first be cast to ints. This h=
as the same issue as above.<div><br></div><div>Another solution is to place=
 all the enum values into a vector&lt;&gt;. This allows for iterating throu=
gh all the values, handles gaps in the sequence. The problem here is that I=
 now have my enum values in two places: in the actual enum definition and i=
n the vector initialization. I need to keep them in sync.</div><div><br></d=
iv><div>I would like to see something like Java's values() method on the en=
um that returns an array (vector) of the enums values. Since all values are=
 know at compile time, this method could easily be constexpr.</div><div><br=
></div><div><div style=3D"background-color:rgb(250,250,250);border:1px soli=
d rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"color:#0=
08">enum</span><span style=3D"color:#000"> </span><span style=3D"color:#008=
">class</span><span style=3D"color:#000"> </span><span style=3D"color:#606"=
>Colors</span><span style=3D"color:#660">{</span><span style=3D"color:#000"=
> red</span><span style=3D"color:#660">=3D</span><span style=3D"color:#066"=
>1</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> gre=
en</span><span style=3D"color:#660">=3D</span><span style=3D"color:#066">5<=
/span><span style=3D"color:#660">,</span><span style=3D"color:#000"> blue</=
span><span style=3D"color:#660">=3D</span><span style=3D"color:#066">10</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">};</span><=
span style=3D"color:#000"><br><br></span><font color=3D"#666600"><span styl=
e=3D"color:#008">for</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000"> color </span><span style=3D"color:#660">:</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">Colors</span><span styl=
e=3D"color:#660">.</span><span style=3D"color:#000">values</span><span styl=
e=3D"color:#660">)</span><span style=3D"color:#000"> </span><span style=3D"=
color:#660">{</span><span style=3D"color:#000"><br></span></font></div></co=
de></div></div><blockquote style=3D"margin:0 0 0 40px;border:none;padding:0=
px"><div style=3D"background-color:rgb(250,250,250);border:1px solid rgb(18=
7,187,187);word-wrap:break-word"><code><div><font color=3D"#666600"><span s=
tyle=3D"color:#800">// do something with each value</span></font></div></co=
de></div></blockquote><div><div style=3D"background-color:rgb(250,250,250);=
border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><font co=
lor=3D"#666600"><span style=3D"color:#660">}</span><span style=3D"color:#00=
0"><br><br></span></font></div></code></div><br><br></div></div></blockquot=
e></div></blockquote></div></div></blockquote></div>

<p></p>

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

------=_Part_4606_817259340.1426102899343--
------=_Part_4605_1225137768.1426102899343--

.


Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Thu, 12 Mar 2015 17:08:52 -0700 (PDT)
Raw View
------=_Part_133_209977612.1426205332121
Content-Type: multipart/alternative;
 boundary="----=_Part_134_778092863.1426205332121"

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

what about this:

enum Color : int { red=3D1, green=3D5, blue=3D10 }

for (auto c : { typedef<Color>... }} {
  cout << "color value=3D" << (int)c;
}



Em ter=C3=A7a-feira, 10 de mar=C3=A7o de 2015 20:53:17 UTC-3, joseph...@gma=
il.com=20
escreveu:
>
> A feature I would like to see in a future language is iterable enums.=20
> Currently, regular C enums are glorified ints and can be advanced using +=
+.=20
> This might not be correct since an enum might contain gaps in the sequenc=
e.=20
> Enum classes completely prohibit arithmetic on its values. They must firs=
t=20
> be cast to ints. This has the same issue as above.
>
> Another solution is to place all the enum values into a vector<>. This=20
> allows for iterating through all the values, handles gaps in the sequence=
..=20
> The problem here is that I now have my enum values in two places: in the=
=20
> actual enum definition and in the vector initialization. I need to keep=
=20
> them in sync.
>
> I would like to see something like Java's values() method on the enum tha=
t=20
> returns an array (vector) of the enums values. Since all values are know =
at=20
> compile time, this method could easily be constexpr.
>
> enum class Colors{ red=3D1, green=3D5, blue=3D10 };
>
> for (auto color : Colors.values) {
>
> // do something with each value
>
> }
>
>
>
>

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

<div dir=3D"ltr">what about this:<div><br></div><div><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 style=3D"color: #008;" class=3D"styled-by-prett=
ify">enum</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Color</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> red</span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"=
color: #660;" class=3D"styled-by-prettify">=3D</span></span><span style=3D"=
color: rgb(0, 102, 102);"><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">1</span></span><span style=3D"color: rgb(102, 102, 0);"><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> green</span><span style=3D"=
color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span></span><span style=3D"color: rgb(0, 102, 102);"><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">5</span></span><span styl=
e=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> blue</span><span style=3D"color: rgb(102, 102, 0);"><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span></span><span styl=
e=3D"color: rgb(0, 102, 102);"><span style=3D"color: #066;" class=3D"styled=
-by-prettify">10</span></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">for</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><font color=3D"=
#000088"><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</sp=
an></font><span style=3D"color: #000;" class=3D"styled-by-prettify"> c </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">typedef</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Color</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&gt;...</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>}</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br>&nbsp; cout </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">"color value=3D"</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code></di=
v><br><br><br>Em ter=C3=A7a-feira, 10 de mar=C3=A7o de 2015 20:53:17 UTC-3,=
 joseph...@gmail.com  escreveu:<blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div dir=3D"ltr">A feature I would like to see in a future language is ite=
rable enums. Currently, regular C enums are glorified ints and can be advan=
ced using ++. This might not be correct since an enum might contain gaps in=
 the sequence. Enum classes completely prohibit arithmetic on its values. T=
hey must first be cast to ints. This has the same issue as above.<div><br><=
/div><div>Another solution is to place all the enum values into a vector&lt=
;&gt;. This allows for iterating through all the values, handles gaps in th=
e sequence. The problem here is that I now have my enum values in two place=
s: in the actual enum definition and in the vector initialization. I need t=
o keep them in sync.</div><div><br></div><div>I would like to see something=
 like Java's values() method on the enum that returns an array (vector) of =
the enums values. Since all values are know at compile time, this method co=
uld easily be constexpr.</div><div><br></div><div><div style=3D"background-=
color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-wo=
rd"><code><div><span style=3D"color:#008">enum</span><span style=3D"color:#=
000"> </span><span style=3D"color:#008">class</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#606">Colors</span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000"> red</span><span style=3D"color:#660=
">=3D</span><span style=3D"color:#066">1</span><span style=3D"color:#660">,=
</span><span style=3D"color:#000"> green</span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#066">5</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> blue</span><span style=3D"color:#660">=3D<=
/span><span style=3D"color:#066">10</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">};</span><span style=3D"color:#000"><br><br></=
span><font color=3D"#666600"><span style=3D"color:#008">for</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#660">(</span><span style=3D=
"color:#008">auto</span><span style=3D"color:#000"> color </span><span styl=
e=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=3D"=
color:#606">Colors</span><span style=3D"color:#660">.</span><span style=3D"=
color:#000">values</span><span style=3D"color:#660">)</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color=
:#000"><br></span></font></div></code></div></div><blockquote style=3D"marg=
in:0 0 0 40px;border:none;padding:0px"><div style=3D"background-color:rgb(2=
50,250,250);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><=
div><font color=3D"#666600"><span style=3D"color:#800">// do something with=
 each value</span></font></div></code></div></blockquote><div><div style=3D=
"background-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-w=
rap:break-word"><code><div><font color=3D"#666600"><span style=3D"color:#66=
0">}</span><span style=3D"color:#000"><br><br></span></font></div></code></=
div><br><br></div></div></blockquote></div></div>

<p></p>

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

------=_Part_134_778092863.1426205332121--
------=_Part_133_209977612.1426205332121--

.