Topic: Let the developer to know number of items in enum at


Author: Konstantin Frumkin <fro0mberg@gmail.com>
Date: Sun, 5 Mar 2017 23:57:49 -0800 (PST)
Raw View
------=_Part_1334_461285828.1488787069628
Content-Type: multipart/alternative;
 boundary="----=_Part_1335_740211968.1488787069628"

------=_Part_1335_740211968.1488787069628
Content-Type: text/plain; charset=UTF-8

For now developers have to use crutches like
enumFoobar{Foo,Bar,Baz,Quz, length =4};



this may be not safe and not robust.
Let the developer access the length value implicitly at compile time like

enumFoobar{foo, bar, baz, quz};
intNumberOfIemsInFoobar=Foobar::length;//

NumberOfIemsInFoobar is 4 during runtime


Make C++ more sweet!

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8cde95ae-23fe-442f-9bf2-5c040f05efde%40isocpp.org.

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

<div dir=3D"ltr">For now developers have to use crutches like <br><div clas=
s=3D"m_-7574783336619094805prettyprint" style=3D"background-color:#fafafa;b=
order-color:#bbbbbb;border-style:solid;border-width:1px"><div class=3D"m_-7=
574783336619094805subprettyprint"><span class=3D"m_-7574783336619094805styl=
ed-by-prettify" style=3D"color:#008">enum</span><span class=3D"m_-757478333=
6619094805styled-by-prettify" style=3D"color:#606">Foobar</span><span class=
=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#660">{</span>=
<span class=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#60=
6">Foo</span><span class=3D"m_-7574783336619094805styled-by-prettify" style=
=3D"color:#660">,</span><span class=3D"m_-7574783336619094805styled-by-pret=
tify" style=3D"color:#606">Bar</span><span class=3D"m_-7574783336619094805s=
tyled-by-prettify" style=3D"color:#660">,</span><span class=3D"m_-757478333=
6619094805styled-by-prettify" style=3D"color:#606">Baz</span><span class=3D=
"m_-7574783336619094805styled-by-prettify" style=3D"color:#660">,</span><sp=
an class=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#606">=
Quz</span><span class=3D"m_-7574783336619094805styled-by-prettify" style=3D=
"color:#660">,</span><span class=3D"m_-7574783336619094805styled-by-prettif=
y" style=3D"color:#000"> length </span><span class=3D"m_-757478333661909480=
5styled-by-prettify" style=3D"color:#660">=3D</span><span class=3D"m_-75747=
83336619094805styled-by-prettify" style=3D"color:#066">4</span><span class=
=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#660">};</span=
><span class=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#0=
00"><br></span></div></div><pre class=3D"m_-7574783336619094805lang-cpp m_-=
7574783336619094805prettyprint m_-7574783336619094805prettyprinted"><code><=
span class=3D"m_-7574783336619094805pun"><br><br>this may be not safe and n=
ot robust.<br>Let the developer access the length value implicitly at compi=
le time like<br></span></code><code></code></pre><div class=3D"m_-757478333=
6619094805prettyprint" style=3D"background-color:#fafafa;border-color:#bbbb=
bb;border-style:solid;border-width:1px"><div class=3D"m_-757478333661909480=
5subprettyprint"><span class=3D"m_-7574783336619094805styled-by-prettify" s=
tyle=3D"color:#008">enum</span><span class=3D"m_-7574783336619094805styled-=
by-prettify" style=3D"color:#606">Foobar</span><span class=3D"m_-7574783336=
619094805styled-by-prettify" style=3D"color:#660">{</span><span class=3D"m_=
-7574783336619094805styled-by-prettify" style=3D"color:#000">foo</span><spa=
n class=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#660">,=
</span><span class=3D"m_-7574783336619094805styled-by-prettify" style=3D"co=
lor:#000"> bar</span><span class=3D"m_-7574783336619094805styled-by-prettif=
y" style=3D"color:#660">,</span><span class=3D"m_-7574783336619094805styled=
-by-prettify" style=3D"color:#000"> baz</span><span class=3D"m_-75747833366=
19094805styled-by-prettify" style=3D"color:#660">,</span><span class=3D"m_-=
7574783336619094805styled-by-prettify" style=3D"color:#000"> quz</span><spa=
n class=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#660">}=
;</span><span class=3D"m_-7574783336619094805styled-by-prettify" style=3D"c=
olor:#000"><br></span><span class=3D"m_-7574783336619094805styled-by-pretti=
fy" style=3D"color:#008">int</span><span class=3D"m_-7574783336619094805sty=
led-by-prettify" style=3D"color:#606">NumberOfIemsInFoobar</span><span clas=
s=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#660">=3D</sp=
an><span class=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:=
#606">Foobar</span><span class=3D"m_-7574783336619094805styled-by-prettify"=
 style=3D"color:#660"><wbr>::</span><span class=3D"m_-7574783336619094805st=
yled-by-prettify" style=3D"color:#000">length</span><span class=3D"m_-75747=
83336619094805styled-by-prettify" style=3D"color:#660">;</span><span class=
=3D"m_-7574783336619094805styled-by-prettify" style=3D"color:#800">// </spa=
n><br><pre class=3D"m_-7574783336619094805lang-cpp m_-7574783336619094805pr=
ettyprint m_-7574783336619094805prettyprinted"><code><code class=3D"m_-7574=
783336619094805prettyprint"><span class=3D"m_-7574783336619094805styled-by-=
prettify" style=3D"color:#606">NumberOfIemsInFoobar</span><span class=3D"m_=
-7574783336619094805styled-by-prettify" style=3D"color:#000"> is 4 during r=
untime</span></code></code></pre></div></div><pre class=3D"m_-7574783336619=
094805lang-cpp m_-7574783336619094805prettyprint m_-7574783336619094805pret=
typrinted"><code><span class=3D"m_-7574783336619094805pun"><br>Make C++ mor=
e sweet!</span></code></pre></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8cde95ae-23fe-442f-9bf2-5c040f05efde%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8cde95ae-23fe-442f-9bf2-5c040f05efde=
%40isocpp.org</a>.<br />

------=_Part_1335_740211968.1488787069628--

------=_Part_1334_461285828.1488787069628--

.