Topic: The last enumerator in an enumeration.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 2 Apr 2013 14:53:11 -0700 (PDT)
Raw View
------=_Part_3846_12042532.1364939591489
Content-Type: text/plain; charset=ISO-8859-1
As an idea. It is not rare that sometimes the last enumerator has to have
the value of the previous enumerator.
For example
enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
So in this example TOTAL_COLORS will be equal to 3. However let assume that
a new color for example White was added.
enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
In this case the value of TOTAL_COLORS becames invalid.
So we need to rewrite the enumeration
enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
It would be good if the value of TOTAL_COLOR will not depend of new added
enumerators.
It could be done using the following syntax
enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
where the asterisk (or something else) would mean the value of the previous
enumerator.
--
---
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/?hl=en.
------=_Part_3846_12042532.1364939591489
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div>As an idea. It is not rare that sometimes the last enumerator has to h=
ave the value of the previous enumerator.</div><div>For example</div><div>&=
nbsp;</div><div>enum { Red, Green, Blue, Black, TOTAL_COLORS =3D Black };</=
div><div> </div><div>So in this example TOTAL_COLORS will be equal to =
3. However let assume that a new color for example White was added.</div><d=
iv> </div><div><div>enum { Red, Green, Blue, Black, White, TOTAL_COLOR=
S =3D Black };</div><div> </div><div>In this case the value of TOTAL_C=
OLORS becames invalid. </div><div>So we need to rewrite the enumeration</di=
v><div> </div><div><div>enum { Red, Green, Blue, Black, White, TOTAL_C=
OLORS =3D White };</div><div> </div></div><div>It would be good i=
f the value of TOTAL_COLOR will not depend of new added enumerators.</div><=
/div><div> </div><div>It could be done using the following syntax</div=
><div> </div><div><div>enum { Red, Green, Blue, Black, White, TOTAL_CO=
LORS =3D * };</div><div> </div><div>where the asterisk (or someth=
ing else) would mean the value of the previous enumerator.</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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_3846_12042532.1364939591489--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 2 Apr 2013 14:57:17 -0700 (PDT)
Raw View
------=_Part_905_12187471.1364939837809
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
>
> As an idea. It is not rare that sometimes the last enumerator has to have
> the value of the previous enumerator.
> For example
>
> enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
>
> So in this example TOTAL_COLORS will be equal to 3. However let assume
> that a new color for example White was added.
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
>
> In this case the value of TOTAL_COLORS becames invalid.
> So we need to rewrite the enumeration
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
>
> It would be good if the value of TOTAL_COLOR will not depend of new added
> enumerators.
>
> It could be done using the following syntax
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
>
> where the asterisk (or something else) would mean the value of the
> previous enumerator.
>
>
To be more correct TOTAL_COLORS could be * + 1 ( White + 1 ):)
>
>
--
---
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/?hl=en.
------=_Part_905_12187471.1364939837809
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote"><div>As an idea. It is not rare that sometimes t=
he last enumerator has to have the value of the previous enumerator.</div><=
div>For example</div><div> </div><div>enum { Red, Green, Blue, Black, =
TOTAL_COLORS =3D Black };</div><div> </div><div>So in this example TOT=
AL_COLORS will be equal to 3. However let assume that a new color for examp=
le White was added.</div><div> </div><div><div>enum { Red, Green, Blue=
, Black, White, TOTAL_COLORS =3D Black };</div><div> </div><div>In thi=
s case the value of TOTAL_COLORS becames invalid. </div><div>So we need to =
rewrite the enumeration</div><div> </div><div><div>enum { Red, Green, =
Blue, Black, White, TOTAL_COLORS =3D White };</div><div> </div></=
div><div>It would be good if the value of TOTAL_COLOR will not depend of ne=
w added enumerators.</div></div><div> </div><div>It could be done usin=
g the following syntax</div><div> </div><div><div>enum { Red, Green, B=
lue, Black, White, TOTAL_COLORS =3D * };</div><div> </div><div>wh=
ere the asterisk (or something else) would mean the value of the =
previous enumerator.</div><div> </div><div></div></div></blockquote><d=
iv> </div><div>To be more correct TOTAL_COLORS could be * + =
1 ( White + 1 ):) </div><blockquote style=3D"margin: 0px 0px 0px 0.8ex=
; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-wid=
th: 1px; border-left-style: solid;" class=3D"gmail_quote"><div><div> <=
/div></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_905_12187471.1364939837809--
.
Author: Lawrence Crowl <crowl@googlers.com>
Date: Tue, 2 Apr 2013 15:16:15 -0700
Raw View
On 4/2/13, Vlad from Moscow <vlad.moscow@mail.ru> wrote:
> On April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
> > As an idea. It is not rare that sometimes the last enumerator
> > has to have the value of the previous enumerator. For example
> >
> > enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
> >
> > So in this example TOTAL_COLORS will be equal to 3. However
> > let assume that a new color for example White was added.
> >
> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
> >
> > In this case the value of TOTAL_COLORS becames invalid. So we
> > need to rewrite the enumeration
> >
> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
> >
> > It would be good if the value of TOTAL_COLOR will not depend
> > of new added enumerators.
> >
> > It could be done using the following syntax
> >
> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
> >
> > where the asterisk (or something else) would mean the value of
> > the previous enumerator.
>
> To be more correct TOTAL_COLORS could be * + 1 ( White + 1 ):)
Why not simply omit the value?
enum { Red, Green, Blue, Black, White, TOTAL_COLORS };
BTW, Ada handled this better, because the value of last enumerator
could be obtained through an attribute.
--
Lawrence Crowl
--
---
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/?hl=en.
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Tue, 2 Apr 2013 15:20:38 -0700 (PDT)
Raw View
------=_Part_813_14160422.1364941238420
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 2:16:15 AM UTC+4, Lawrence Crowl wrote:
>
> On 4/2/13, Vlad from Moscow <vlad....@mail.ru <javascript:>> wrote:
> > On April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
> > > As an idea. It is not rare that sometimes the last enumerator
> > > has to have the value of the previous enumerator. For example
> > >
> > > enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
> > >
> > > So in this example TOTAL_COLORS will be equal to 3. However
> > > let assume that a new color for example White was added.
> > >
> > > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
> > >
> > > In this case the value of TOTAL_COLORS becames invalid. So we
> > > need to rewrite the enumeration
> > >
> > > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
> > >
> > > It would be good if the value of TOTAL_COLOR will not depend
> > > of new added enumerators.
> > >
> > > It could be done using the following syntax
> > >
> > > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
> > >
> > > where the asterisk (or something else) would mean the value of
> > > the previous enumerator.
> >
> > To be more correct TOTAL_COLORS could be * + 1 ( White + 1 ):)
>
> Why not simply omit the value?
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS };
>
> BTW, Ada handled this better, because the value of last enumerator
> could be obtained through an attribute.
>
> --
> Lawrence Crowl
>
I showed not very good example, but I was saying about the requirements to
have the value of a previous enumerator irrespective of what the previous
enumerator name is..
--
---
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/?hl=en.
------=_Part_813_14160422.1364941238420
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 2:16:15 AM UTC+4, Lawrence Crowl wrote:<blo=
ckquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-=
color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid=
;" class=3D"gmail_quote">On 4/2/13, Vlad from Moscow <<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"9qZH902ZoK4J">vlad....@mai=
l.ru</a>> wrote:
<br>> On April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
<br>> > As an idea. It is not rare that sometimes the last enumerator
<br>> > has to have the value of the previous enumerator. For e=
xample
<br>> >
<br>> > enum { Red, Green, Blue, Black, TOTAL_COLORS =3D Black };
<br>> >
<br>> > So in this example TOTAL_COLORS will be equal to 3. However
<br>> > let assume that a new color for example White was added.
<br>> >
<br>> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D Black=
};
<br>> >
<br>> > In this case the value of TOTAL_COLORS becames invalid.  =
;So we
<br>> > need to rewrite the enumeration
<br>> >
<br>> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D White=
};
<br>> >
<br>> > It would be good if the value of TOTAL_COLOR will not depend
<br>> > of new added enumerators.
<br>> >
<br>> > It could be done using the following syntax
<br>> >
<br>> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D * };
<br>> >
<br>> > where the asterisk (or something else) would mean the value o=
f
<br>> > the previous enumerator.
<br>>
<br>> To be more correct TOTAL_COLORS could be * + 1 ( White + 1 ):)
<br>
<br>Why not simply omit the value?
<br>
<br>enum { Red, Green, Blue, Black, White, TOTAL_COLORS };
<br>
<br>BTW, Ada handled this better, because the value of last enumerator
<br>could be obtained through an attribute.
<br>
<br>--=20
<br>Lawrence Crowl
<br></blockquote><div> </div><div> </div><div>I showed not v=
ery good example, but I was saying about the requirements to have the =
value of a previous enumerator irrespective of what the previous enumerator=
name is.. </div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_813_14160422.1364941238420--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 2 Apr 2013 17:30:59 -0700 (PDT)
Raw View
------=_Part_3136_23425555.1364949059278
Content-Type: text/plain; charset=ISO-8859-1
On Tuesday, April 2, 2013 3:20:38 PM UTC-7, Vlad from Moscow wrote:
>
>
> On Wednesday, April 3, 2013 2:16:15 AM UTC+4, Lawrence Crowl wrote:
>>
>> On 4/2/13, Vlad from Moscow <vlad....@mail.ru> wrote:
>> > On April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
>> > > As an idea. It is not rare that sometimes the last enumerator
>> > > has to have the value of the previous enumerator. For example
>> > >
>> > > enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
>> > >
>> > > So in this example TOTAL_COLORS will be equal to 3. However
>> > > let assume that a new color for example White was added.
>> > >
>> > > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
>> > >
>> > > In this case the value of TOTAL_COLORS becames invalid. So we
>> > > need to rewrite the enumeration
>> > >
>> > > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
>> > >
>> > > It would be good if the value of TOTAL_COLOR will not depend
>> > > of new added enumerators.
>> > >
>> > > It could be done using the following syntax
>> > >
>> > > enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
>> > >
>> > > where the asterisk (or something else) would mean the value of
>> > > the previous enumerator.
>> >
>> > To be more correct TOTAL_COLORS could be * + 1 ( White + 1 ):)
>>
>> Why not simply omit the value?
>>
>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS };
>>
>> BTW, Ada handled this better, because the value of last enumerator
>> could be obtained through an attribute.
>>
>> --
>> Lawrence Crowl
>>
>
>
> I showed not very good example, but I was saying about the requirements to
> have the value of a previous enumerator irrespective of what the previous
> enumerator name is..
>
But if we could have that, we could also have a "largest enum" construct
that, given an enumeration, returns the largest defined value. I don't see
the need in adding a feature that exists solely to support something that
we should be doing in a different way.
--
---
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/?hl=en.
------=_Part_3136_23425555.1364949059278
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
On Tuesday, April 2, 2013 3:20:38 PM UTC-7, Vlad from Moscow wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><br>On Wednesday, April 3, 2013 2:16:1=
5 AM UTC+4, Lawrence Crowl wrote:<blockquote style=3D"margin:0px 0px 0px 0.=
8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid" class=3D"gmail_quote">On 4/2/13, Vlad from Mosc=
ow <<a>vlad....@mail.ru</a>> wrote:
<br>> On April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
<br>> > As an idea. It is not rare that sometimes the last enumerator
<br>> > has to have the value of the previous enumerator. For e=
xample
<br>> >
<br>> > enum { Red, Green, Blue, Black, TOTAL_COLORS =3D Black };
<br>> >
<br>> > So in this example TOTAL_COLORS will be equal to 3. However
<br>> > let assume that a new color for example White was added.
<br>> >
<br>> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D Black=
};
<br>> >
<br>> > In this case the value of TOTAL_COLORS becames invalid.  =
;So we
<br>> > need to rewrite the enumeration
<br>> >
<br>> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D White=
};
<br>> >
<br>> > It would be good if the value of TOTAL_COLOR will not depend
<br>> > of new added enumerators.
<br>> >
<br>> > It could be done using the following syntax
<br>> >
<br>> > enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D * };
<br>> >
<br>> > where the asterisk (or something else) would mean the value o=
f
<br>> > the previous enumerator.
<br>>
<br>> To be more correct TOTAL_COLORS could be * + 1 ( White + 1 ):)
<br>
<br>Why not simply omit the value?
<br>
<br>enum { Red, Green, Blue, Black, White, TOTAL_COLORS };
<br>
<br>BTW, Ada handled this better, because the value of last enumerator
<br>could be obtained through an attribute.
<br>
<br>--=20
<br>Lawrence Crowl
<br></blockquote><div> </div><div> </div><div>I showed not v=
ery good example, but I was saying about the requirements to have the =
value of a previous enumerator irrespective of what the previous enumerator=
name is.. </div></blockquote><div><br>But if we could have that=
, we could also have a "largest enum" construct that, given an enumeration,=
returns the largest defined value. I don't see the need in adding a featur=
e that exists solely to support something that we should be doing in a diff=
erent way.<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_3136_23425555.1364949059278--
.
Author: Shakti Misra <shakti.misra.study@gmail.com>
Date: Wed, 3 Apr 2013 12:16:31 +0530
Raw View
--047d7b621b14d69d3a04d96f368c
Content-Type: text/plain; charset=ISO-8859-1
Many a times I have seen the need for this. Why not just have something
like this:
enum s{...};
s.length. This can be calculated by compiler at compile time and
convenient. Can there be something for having a invalid value as a const
expression also?
--
---
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/?hl=en.
--047d7b621b14d69d3a04d96f368c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>Many a times I have seen the need for this. Why =
not just have something like this:<br><br></div>enum s{...};<br><br></div>s=
..length. This can be calculated by compiler at compile time and convenient.=
Can there be something for having a invalid value as a const expression al=
so?<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--047d7b621b14d69d3a04d96f368c--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 00:32:23 -0700 (PDT)
Raw View
------=_Part_1112_24950044.1364974343779
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 10:46:31 AM UTC+4, Shakti Misra wrote:
>
> Many a times I have seen the need for this. Why not just have something
> like this:
>
> enum s{...};
>
> s.length. This can be calculated by compiler at compile time and
> convenient. Can there be something for having a invalid value as a const
> expression also?
>
>
Maybe to allow such a construction as sizeof( SomeEnumeration)?
enum Color { Red = 1, Green, Blue };
std::cout << sizeof( Color ) << std::endl; // displays 3
And inside the definition to use
enum Color { Red = 1, Green, Blue, Total_Colors = Color[sizeof( Color) - 1]
};
That is 1) to allow to use sizeof( SomeEnumeration ) inside and outside
anumeration and 2) to use the array syntaxical record for accessing
enumerators inside enumerator definition.
--
---
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/?hl=en.
------=_Part_1112_24950044.1364974343779
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 10:46:31 AM UTC+4, Shakti Misra wrote:<bloc=
kquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-c=
olor: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;=
" class=3D"gmail_quote"><div dir=3D"ltr"><div><div>Many a times I have seen=
the need for this. Why not just have something like this:<br><br></div>enu=
m s{...};<br><br></div>s.length. This can be calculated by compiler at comp=
ile time and convenient. Can there be something for having a invalid value =
as a const expression also?<br>
</div><div dir=3D"ltr"> </div></blockquote><div> </div><div>Maybe=
to allow such a construction as sizeof( SomeEnumeration)?</div><div> =
</div><div>enum Color { Red =3D 1, Green, Blue };</div><div> </di=
v><div>std::cout << sizeof( Color ) << std::endl; // displ=
ays 3</div><div> </div><div>And inside the definition to use</div><div=
> </div><div>enum Color { Red =3D 1, Green, Blue, Total_Colors =3D Col=
or[sizeof( Color) - 1] }; </div><div> </div><div>That is 1) to al=
low to use sizeof( SomeEnumeration ) inside and outside anumeration and 2) =
to use the array syntaxical record for accessing enumerators inside&nb=
sp;enumerator definition. </div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_1112_24950044.1364974343779--
.
Author: Shakti Misra <shakti.misra.study@gmail.com>
Date: Wed, 3 Apr 2013 13:06:37 +0530
Raw View
--089e0160c9be05dbcf04d96feabe
Content-Type: text/plain; charset=ISO-8859-1
I like the idea a sizeof(enum) it is more clear than having enum.size.
--
---
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/?hl=en.
--089e0160c9be05dbcf04d96feabe
Content-Type: text/html; charset=ISO-8859-1
<div dir="ltr">I like the idea a sizeof(enum) it is more clear than having enum.size. <br></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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
<br />
<br />
--089e0160c9be05dbcf04d96feabe--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 00:37:59 -0700 (PDT)
Raw View
------=_Part_2110_31080077.1364974679030
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 11:32:23 AM UTC+4, Vlad from Moscow wrote:
>
>
> On Wednesday, April 3, 2013 10:46:31 AM UTC+4, Shakti Misra wrote:
>>
>> Many a times I have seen the need for this. Why not just have something
>> like this:
>>
>> enum s{...};
>>
>> s.length. This can be calculated by compiler at compile time and
>> convenient. Can there be something for having a invalid value as a const
>> expression also?
>>
>>
>
> Maybe to allow such a construction as sizeof( SomeEnumeration)?
>
> enum Color { Red = 1, Green, Blue };
>
> std::cout << sizeof( Color ) << std::endl; // displays 3
>
> And inside the definition to use
>
> enum Color { Red = 1, Green, Blue, Total_Colors = Color[sizeof( Color) -
> 1] };
>
> That is 1) to allow to use sizeof( SomeEnumeration ) inside and outside
> anumeration and 2) to use the array syntaxical record for accessing
> enumerators inside enumerator definition.
>
>
As an example
enum Color { Red = sizeof( Color ) + 1, Green = sizeof( Color ) + 1, Blue =
sizeof(Color ) + 1, Total_Color = Color[sizeof(Color ) - 1] };
// Red == 1, Green == 2, Blue == 3,Total_Color = 3
And outside the definition
std::cout << sizeof( Color ) << std::endl;
// output is 4
--
---
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/?hl=en.
------=_Part_2110_31080077.1364974679030
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 11:32:23 AM UTC+4, Vlad from Moscow wrote:<=
blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-le=
ft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: so=
lid;" class=3D"gmail_quote"><br>On Wednesday, April 3, 2013 10:46:31 AM UTC=
+4, Shakti Misra wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padd=
ing-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1p=
x; border-left-style: solid;" class=3D"gmail_quote"><div dir=3D"ltr"><div><=
div>Many a times I have seen the need for this. Why not just have something=
like this:<br><br></div>enum s{...};<br><br></div>s.length. This can be ca=
lculated by compiler at compile time and convenient. Can there be something=
for having a invalid value as a const expression also?<br>
</div><div dir=3D"ltr"> </div></blockquote><div> </div><div>Maybe=
to allow such a construction as sizeof( SomeEnumeration)?</div><div> =
</div><div>enum Color { Red =3D 1, Green, Blue };</div><div> </di=
v><div>std::cout << sizeof( Color ) << std::endl; // displ=
ays 3</div><div> </div><div>And inside the definition to use</div><div=
> </div><div>enum Color { Red =3D 1, Green, Blue, Total_Colors =3D Col=
or[sizeof( Color) - 1] }; </div><div> </div><div>That is 1) to al=
low to use sizeof( SomeEnumeration ) inside and outside anumeration and 2) =
to use the array syntaxical record for accessing enumerators inside&nb=
sp;enumerator definition. </div><div> </div></blockquote><d=
iv> </div><div>As an example</div><div> </div><div> </div><d=
iv>enum Color { Red =3D sizeof( Color ) + 1, Green =3D sizeof( Co=
lor ) + 1, Blue =3D sizeof(Color ) + 1, Total_Color =3D Color[sizeof(C=
olor ) - 1] };</div><div> </div><div>// Red =3D=3D 1, Green =3D=3D 2, =
Blue =3D=3D 3,Total_Color =3D 3</div><div> </div><div>And outside the =
definition</div><div> </div><div>std::cout << sizeof( Color ) &l=
t;< std::endl;</div><div> </div><div>// output is 4 </div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_2110_31080077.1364974679030--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 00:42:59 -0700 (PDT)
Raw View
------=_Part_1094_29759537.1364974979493
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 11:37:59 AM UTC+4, Vlad from Moscow wrote:
>
>
> On Wednesday, April 3, 2013 11:32:23 AM UTC+4, Vlad from Moscow wrote:
>>
>>
>> On Wednesday, April 3, 2013 10:46:31 AM UTC+4, Shakti Misra wrote:
>>>
>>> Many a times I have seen the need for this. Why not just have something
>>> like this:
>>>
>>> enum s{...};
>>>
>>> s.length. This can be calculated by compiler at compile time and
>>> convenient. Can there be something for having a invalid value as a const
>>> expression also?
>>>
>>>
>>
>> Maybe to allow such a construction as sizeof( SomeEnumeration)?
>>
>> enum Color { Red = 1, Green, Blue };
>>
>> std::cout << sizeof( Color ) << std::endl; // displays 3
>>
>> And inside the definition to use
>>
>> enum Color { Red = 1, Green, Blue, Total_Colors = Color[sizeof( Color) -
>> 1] };
>>
>> That is 1) to allow to use sizeof( SomeEnumeration ) inside and outside
>> anumeration and 2) to use the array syntaxical record for accessing
>> enumerators inside enumerator definition.
>>
>>
>
> As an example
>
>
> enum Color { Red = sizeof( Color ) + 1, Green = sizeof( Color ) + 1, Blue
> = sizeof(Color ) + 1, Total_Color = Color[sizeof(Color ) - 1] };
>
> // Red == 1, Green == 2, Blue == 3,Total_Color = 3
>
> And outside the definition
>
> std::cout << sizeof( Color ) << std::endl;
>
> // output is 4
>
>
Instead of sizeof( SomeEnumeration ) in the examples above
sizeof...(SomeEnumeration ) could be used
--
---
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/?hl=en.
------=_Part_1094_29759537.1364974979493
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 11:37:59 AM UTC+4, Vlad from Moscow wrote:<=
blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-le=
ft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: so=
lid;" class=3D"gmail_quote"><br>On Wednesday, April 3, 2013 11:32:23 AM UTC=
+4, Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;" class=3D"gmail_quote"><br>On Wednesday, A=
pril 3, 2013 10:46:31 AM UTC+4, Shakti Misra wrote:<blockquote style=3D"mar=
gin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204,=
204); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_qu=
ote"><div dir=3D"ltr"><div><div>Many a times I have seen the need for this.=
Why not just have something like this:<br><br></div>enum s{...};<br><br></=
div>s.length. This can be calculated by compiler at compile time and conven=
ient. Can there be something for having a invalid value as a const expressi=
on also?<br>
</div><div dir=3D"ltr"> </div></blockquote><div> </div><div>Maybe=
to allow such a construction as sizeof( SomeEnumeration)?</div><div> =
</div><div>enum Color { Red =3D 1, Green, Blue };</div><div> </di=
v><div>std::cout << sizeof( Color ) << std::endl; // displ=
ays 3</div><div> </div><div>And inside the definition to use</div><div=
> </div><div>enum Color { Red =3D 1, Green, Blue, Total_Colors =3D Col=
or[sizeof( Color) - 1] }; </div><div> </div><div>That is 1) to al=
low to use sizeof( SomeEnumeration ) inside and outside anumeration and 2) =
to use the array syntaxical record for accessing enumerators inside&nb=
sp;enumerator definition. </div><div> </div></blockquote><d=
iv> </div><div>As an example</div><div> </div><div> </div><d=
iv>enum Color { Red =3D sizeof( Color ) + 1, Green =3D sizeof( Co=
lor ) + 1, Blue =3D sizeof(Color ) + 1, Total_Color =3D Color[sizeof(C=
olor ) - 1] };</div><div> </div><div>// Red =3D=3D 1, Green =3D=3D 2, =
Blue =3D=3D 3,Total_Color =3D 3</div><div> </div><div>And outside the =
definition</div><div> </div><div>std::cout << sizeof( Color ) &l=
t;< std::endl;</div><div> </div><div>// output is 4 </div><div=
> </div></blockquote><div> </div><div>Instead of sizeof( SomeEnum=
eration ) in the examples above sizeof...(SomeEnumeration ) could be u=
sed </div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_1094_29759537.1364974979493--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Wed, 3 Apr 2013 09:46:47 +0200
Raw View
--f46d043c7f1a5a5b9e04d9700e60
Content-Type: text/plain; charset=ISO-8859-1
2013/4/3 Vlad from Moscow <vlad.moscow@mail.ru>
> Maybe to allow such a construction as sizeof( SomeEnumeration)?
>
> enum Color { Red = 1, Green, Blue };
>
> std::cout << sizeof( Color ) << std::endl; // displays 3
>
> And inside the definition to use
>
> enum Color { Red = 1, Green, Blue, Total_Colors = Color[sizeof( Color) -
> 1] };
>
> That is 1) to allow to use sizeof( SomeEnumeration ) inside and outside
> anumeration and 2) to use the array syntaxical record for accessing
> enumerators inside enumerator definition.
>
Using sizeof requires a complete type. Enum type Color cannot be assumed to
be complete at this point, so this should be ill-formed. Note that core
issue
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#977
via
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1482
is going to clarify this point.
- Daniel
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
--f46d043c7f1a5a5b9e04d9700e60
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
2013/4/3 Vlad from Moscow <span dir=3D"ltr"><<a href=3D"mailto:vlad.mosc=
ow@mail.ru" target=3D"_blank">vlad.moscow@mail.ru</a>></span><br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">
<div>Maybe to allow such a construction as sizeof( SomeEnumeration)?</div><=
div>=A0</div><div>enum=A0Color { Red =3D 1, Green, Blue };</div><div>=A0</d=
iv><div>std::cout << sizeof( Color ) << std::endl; //=A0display=
s 3</div>
<div>=A0</div><div>And inside the definition to use</div><div>=A0</div><div=
>enum Color { Red =3D 1, Green, Blue, Total_Colors =3D Color[sizeof( Color)=
- 1] };=A0</div><div>=A0</div><div>That is 1) to allow to use sizeof( Some=
Enumeration ) inside and outside anumeration and 2) to use=A0the array synt=
axical record for accessing enumerators inside=A0enumerator definition.=A0=
=A0</div>
</blockquote><div><br></div><div>Using sizeof requires a complete type. Enu=
m type Color cannot be assumed to be complete at this point, so this should=
be ill-formed. Note that core issue <br><br><a href=3D"http://www.open-std=
..org/jtc1/sc22/wg21/docs/cwg_active.html#977">http://www.open-std.org/jtc1/=
sc22/wg21/docs/cwg_active.html#977</a><br>
<br></div><div>via<br><br><a href=3D"http://www.open-std.org/jtc1/sc22/wg21=
/docs/cwg_active.html#1482">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg=
_active.html#1482</a><br><br></div><div>is going to clarify this point.<br>
<br></div><div>- Daniel<br></div></div><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--f46d043c7f1a5a5b9e04d9700e60--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Wed, 3 Apr 2013 10:10:41 +0200
Raw View
--001a11c27ee4ddb17004d97063c2
Content-Type: text/plain; charset=ISO-8859-1
2013/4/3 Vlad from Moscow <vlad.moscow@mail.ru>
>
> On Wednesday, April 3, 2013 11:37:59 AM UTC+4, Vlad from Moscow wrote:
>>
>> As an example
>>
>>
>> enum Color { Red = sizeof( Color ) + 1, Green = sizeof( Color ) + 1, Blue
>> = sizeof(Color ) + 1, Total_Color = Color[sizeof(Color ) - 1] };
>>
>> // Red == 1, Green == 2, Blue == 3,Total_Color = 3
>>
>> And outside the definition
>>
>> std::cout << sizeof( Color ) << std::endl;
>>
>> // output is 4
>>
>>
>
> Instead of sizeof( SomeEnumeration ) in the examples above
> sizeof...(SomeEnumeration ) could be used
>
Using either of sizeof or sizeof... for this purpose looks wrong to me: In
regard to sizeof() it would change the meaning of currently valid code, in
regard to sizeof...() it would not match the intention of this operator
(for parameter packs). I would strongly recommend to make this
functionality available via library traits instead.
- Daniel
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
--001a11c27ee4ddb17004d97063c2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
2013/4/3 Vlad from Moscow <span dir=3D"ltr"><<a href=3D"mailto:vlad.mosc=
ow@mail.ru" target=3D"_blank">vlad.moscow@mail.ru</a>></span><br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">
<div class=3D"im"><br>On Wednesday, April 3, 2013 11:37:59 AM UTC+4, Vlad f=
rom Moscow wrote:<blockquote style=3D"margin:0px 0px 0px 0.8ex;padding-left=
:1ex;border-left:1px solid rgb(204,204,204)" class=3D"gmail_quote">As an ex=
ample<div>
=A0</div><div>=A0</div><div>enum=A0Color { Red =3D sizeof( Color )=A0+ 1, G=
reen =3D sizeof( Color=A0) + 1, Blue =3D sizeof(Color ) + 1, Total_Color =
=3D Color[sizeof(Color ) - 1] };</div><div>=A0</div><div>// Red =3D=3D 1, G=
reen =3D=3D 2, Blue =3D=3D 3,Total_Color =3D 3</div>
<div>=A0</div><div>And outside the definition</div><div>=A0</div><div>std::=
cout << sizeof( Color ) << std::endl;</div><div>=A0</div><div>/=
/ output is 4=A0</div><div>=A0</div></blockquote><div>=A0</div></div><div>I=
nstead of sizeof( SomeEnumeration ) in the examples above sizeof...(SomeEnu=
meration )=A0could be used=A0</div>
</blockquote><div><br></div><div>Using either of sizeof or sizeof... for th=
is purpose looks wrong to me: In regard to sizeof() it would change the mea=
ning of currently valid code, in regard to sizeof...() it would not match t=
he intention of this operator (for parameter packs). I would strongly recom=
mend to make this functionality available via library traits instead.<br>
<br></div><div>- Daniel<br></div><div>=A0</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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--001a11c27ee4ddb17004d97063c2--
.
Author: Shakti Misra <shakti.misra.study@gmail.com>
Date: Wed, 3 Apr 2013 13:52:32 +0530
Raw View
--089e0160c9be3fdd6e04d9708ec1
Content-Type: text/plain; charset=ISO-8859-1
Why not have
enum E{...};
E.size. This can always be a compiler constant?
--
---
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/?hl=en.
--089e0160c9be3fdd6e04d9708ec1
Content-Type: text/html; charset=ISO-8859-1
<div dir="ltr"><div><div>Why not have <br></div>enum E{...};<br><br></div>E.size. This can always be a compiler constant?<br></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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
<br />
<br />
--089e0160c9be3fdd6e04d9708ec1--
.
Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Wed, 3 Apr 2013 10:58:05 +0200
Raw View
--001a11c27ee457958c04d9710d91
Content-Type: text/plain; charset=ISO-8859-1
2013/4/3 Shakti Misra <shakti.misra.study@gmail.com>
> Why not have
> enum E{...};
>
> E.size. This can always be a compiler constant?
>
>
>
Technically this would be possible, but generally library solutions are a
preferred approach, if they can realize the same thing. It is much more
costly to modify the core language instead of modifying the standard
library.
- Daniel
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
--001a11c27ee457958c04d9710d91
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
2013/4/3 Shakti Misra <span dir=3D"ltr"><<a href=3D"mailto:shakti.misra.=
study@gmail.com" target=3D"_blank">shakti.misra.study@gmail.com</a>></sp=
an><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr"><div><div>Why not have <br></div>enum E{...};<br><br></div=
>E.size. This can always be a compiler constant?<br></div><div class=3D"HOE=
nZb"><div class=3D"h5">
<p></p><br></div></div></blockquote></div><br></div><div class=3D"gmail_ext=
ra">Technically this would be possible, but generally library solutions are=
a preferred approach, if they can realize the same thing. It is much more =
costly to modify the core language instead of modifying the standard librar=
y.<br>
<br></div><div class=3D"gmail_extra">- Daniel<br><br></div><div class=3D"gm=
ail_extra"><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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--001a11c27ee457958c04d9710d91--
.
Author: Shakti Misra <shakti.misra.study@gmail.com>
Date: Wed, 3 Apr 2013 14:38:00 +0530
Raw View
--089e01634030d19e6c04d9713014
Content-Type: text/plain; charset=ISO-8859-1
Yes, that is the way i generally do it. Mostly what i do is i have a
template<typename T>
size_of; which returns me the sizes. and a template<typename T>invalid_type
which return the invalid 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/?hl=en.
--089e01634030d19e6c04d9713014
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>Yes, that is the way i generally do it. Mostly w=
hat i do is i have a <br></div>template<typename T><br></div>size_of;=
which returns me the sizes. and a template<typename T>invalid_type w=
hich return the invalid value.<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--089e01634030d19e6c04d9713014--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 02:18:03 -0700 (PDT)
Raw View
------=_Part_208_17225730.1364980683557
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
>
> As an idea. It is not rare that sometimes the last enumerator has to have
> the value of the previous enumerator.
> For example
>
> enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
>
> So in this example TOTAL_COLORS will be equal to 3. However let assume
> that a new color for example White was added.
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
>
> In this case the value of TOTAL_COLORS becames invalid.
> So we need to rewrite the enumeration
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
>
> It would be good if the value of TOTAL_COLOR will not depend of new added
> enumerators.
>
> It could be done using the following syntax
>
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
>
> where the asterisk (or something else) would mean the value of the
> previous enumerator.
>
>
I'd like to summarize the main ideas.
To make accessiable the value of the previous enumerator to the current
enumerator without referencing the name of the previous enumerator.
To make some sort of indexed access to values of previous enumerators
inside the definition of enumerator as for example
enum Color { Red, Blue, Green, Black = Color[0] + Color[1] + Color[2] };
>
>
--
---
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/?hl=en.
------=_Part_208_17225730.1364980683557
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote"><div>As an idea. It is not rare that sometimes t=
he last enumerator has to have the value of the previous enumerator.</div><=
div>For example</div><div> </div><div>enum { Red, Green, Blue, Black, =
TOTAL_COLORS =3D Black };</div><div> </div><div>So in this example TOT=
AL_COLORS will be equal to 3. However let assume that a new color for examp=
le White was added.</div><div> </div><div><div>enum { Red, Green, Blue=
, Black, White, TOTAL_COLORS =3D Black };</div><div> </div><div>In thi=
s case the value of TOTAL_COLORS becames invalid. </div><div>So we need to =
rewrite the enumeration</div><div> </div><div><div>enum { Red, Green, =
Blue, Black, White, TOTAL_COLORS =3D White };</div><div> </div></=
div><div>It would be good if the value of TOTAL_COLOR will not depend of ne=
w added enumerators.</div></div><div> </div><div>It could be done usin=
g the following syntax</div><div> </div><div><div>enum { Red, Green, B=
lue, Black, White, TOTAL_COLORS =3D * };</div><div> </div><div>wh=
ere the asterisk (or something else) would mean the value of the =
previous enumerator.</div><div> </div><div></div></div></blockquote><d=
iv> </div><div> </div><div>I'd like to summarize the main id=
eas. </div><div> </div><div>To make accessiable the value of the =
previous enumerator to the current enumerator without referencing the =
name of the previous enumerator. </div><div> </div><div>To make s=
ome sort of indexed access to values of previous enumerators inside th=
e definition of enumerator as for example </div><div> </div><div>=
enum Color { Red, Blue, Green, Black =3D Color[0] + Color[1] + Color[2] };<=
/div><div> </div><blockquote 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;" class=3D"gmail_quote"><div><div> </div></=
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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_208_17225730.1364980683557--
.
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Wed, 3 Apr 2013 11:19:17 +0200
Raw View
On Wed, Apr 3, 2013 at 10:22 AM, Shakti Misra
<shakti.misra.study@gmail.com> wrote:
> Why not have
> enum E{...};
>
> E.size. This can always be a compiler constant?
What does .size return for enum E{a, b=4}? or enum E{a,b=a}? IMO, enum
traits would be useful, but they need to be specified precisely.
--
---
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/?hl=en.
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 02:23:08 -0700 (PDT)
Raw View
------=_Part_801_30300514.1364980988395
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 1:18:03 PM UTC+4, Vlad from Moscow wrote:
>
>
> On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
>>
>> As an idea. It is not rare that sometimes the last enumerator has to have
>> the value of the previous enumerator.
>> For example
>>
>> enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
>>
>> So in this example TOTAL_COLORS will be equal to 3. However let assume
>> that a new color for example White was added.
>>
>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
>>
>> In this case the value of TOTAL_COLORS becames invalid.
>> So we need to rewrite the enumeration
>>
>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
>>
>> It would be good if the value of TOTAL_COLOR will not depend of new added
>> enumerators.
>>
>> It could be done using the following syntax
>>
>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
>>
>> where the asterisk (or something else) would mean the value of the
>> previous enumerator.
>>
>>
>
>
> I'd like to summarize the main ideas.
>
> To make accessiable the value of the previous enumerator to the current
> enumerator without referencing the name of the previous enumerator.
>
> To make some sort of indexed access to values of previous enumerators
> inside the definition of enumerator as for example
>
> enum Color { Red, Blue, Green, Black = Color[0] + Color[1] + Color[2] };
>
>
>>
I made a typo. Shall be
To make some sort of indexed access to values of previous enumerators
inside the definition of an enumeration...
>
>>
>
--
---
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/?hl=en.
------=_Part_801_30300514.1364980988395
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 1:18:03 PM UTC+4, Vlad from Moscow wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote"><br>On Wednesday, April 3, 2013 1:53:11 AM UTC+4=
, Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; pa=
dding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: =
1px; border-left-style: solid;" class=3D"gmail_quote"><div>As an idea. It i=
s not rare that sometimes the last enumerator has to have the value of the =
previous enumerator.</div><div>For example</div><div> </div><div>enum =
{ Red, Green, Blue, Black, TOTAL_COLORS =3D Black };</div><div> </div>=
<div>So in this example TOTAL_COLORS will be equal to 3. However let assume=
that a new color for example White was added.</div><div> </div><div><=
div>enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D Black };</div><=
div> </div><div>In this case the value of TOTAL_COLORS becames invalid=
.. </div><div>So we need to rewrite the enumeration</div><div> </div><d=
iv><div>enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D White =
};</div><div> </div></div><div>It would be good if the value of TOTAL_=
COLOR will not depend of new added enumerators.</div></div><div> </div=
><div>It could be done using the following syntax</div><div> </div><di=
v><div>enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D * };</d=
iv><div> </div><div>where the asterisk (or something else) would =
mean the value of the previous enumerator.</div><div> </div><div>=
</div></div></blockquote><div> </div><div> </div><div>I'd like to=
summarize the main ideas. </div><div> </div><div>To make accessi=
able the value of the previous enumerator to the current enumerator&nb=
sp;without referencing the name of the previous enumerator. </div><div=
> </div><div>To make some sort of indexed access to values of previous=
enumerators inside the definition of enumerator as for example <=
/div><div> </div><div>enum Color { Red, Blue, Green, Black =3D Color[0=
] + Color[1] + Color[2] };</div><div> </div><blockquote style=3D"margi=
n: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 2=
04); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_quot=
e"><div><div></div></div></blockquote></blockquote><div> </div><div>I =
made a typo. Shall be</div><div> </div><div>To make some sort of index=
ed access to values of previous enumerators inside the definition of an enu=
meration...</div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-le=
ft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bor=
der-left-style: solid;" class=3D"gmail_quote"><blockquote style=3D"margin: =
0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204)=
; border-left-width: 1px; border-left-style: solid;" class=3D"gmail_quote">=
<div><div> </div></div></blockquote></blockquote>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_801_30300514.1364980988395--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 02:34:15 -0700 (PDT)
Raw View
------=_Part_40_11249494.1364981655622
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 1:23:08 PM UTC+4, Vlad from Moscow wrote:
>
>
> On Wednesday, April 3, 2013 1:18:03 PM UTC+4, Vlad from Moscow wrote:
>>
>>
>> On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
>>>
>>> As an idea. It is not rare that sometimes the last enumerator has to
>>> have the value of the previous enumerator.
>>> For example
>>>
>>> enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
>>>
>>> So in this example TOTAL_COLORS will be equal to 3. However let assume
>>> that a new color for example White was added.
>>>
>>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
>>>
>>> In this case the value of TOTAL_COLORS becames invalid.
>>> So we need to rewrite the enumeration
>>>
>>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
>>>
>>> It would be good if the value of TOTAL_COLOR will not depend of new
>>> added enumerators.
>>>
>>> It could be done using the following syntax
>>>
>>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
>>>
>>> where the asterisk (or something else) would mean the value of the
>>> previous enumerator.
>>>
>>>
>>
>>
>> I'd like to summarize the main ideas.
>>
>> To make accessiable the value of the previous enumerator to the current
>> enumerator without referencing the name of the previous enumerator.
>>
>> To make some sort of indexed access to values of previous enumerators
>> inside the definition of enumerator as for example
>>
>> enum Color { Red, Blue, Green, Black = Color[0] + Color[1] + Color[2] };
>>
>>
>>>
> I made a typo. Shall be
>
> To make some sort of indexed access to values of previous enumerators
> inside the definition of an enumeration...
>
>
By the way the both goals can be achieved by using indexing. For example
the value of the previous enumerator can be obtained by using syntax
> enum Color { Red = 1, Blue = 2, Green = 4, Black = Color[0] | Color[1] |
> Color[2], TotalColor = Color[-1] };
>
>
That is a negative index will provide the access to previous enumerators.:)
>
>
>>
>>>
>>
--
---
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/?hl=en.
------=_Part_40_11249494.1364981655622
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 1:23:08 PM UTC+4, Vlad from Moscow wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote"><br>On Wednesday, April 3, 2013 1:18:03 PM UTC+4=
, Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; pa=
dding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: =
1px; border-left-style: solid;" class=3D"gmail_quote"><br>On Wednesday, Apr=
il 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:<blockquote style=3D"ma=
rgin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204=
, 204); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_q=
uote"><div>As an idea. It is not rare that sometimes the last enumerator ha=
s to have the value of the previous enumerator.</div><div>For example</div>=
<div> </div><div>enum { Red, Green, Blue, Black, TOTAL_COLORS =3D Blac=
k };</div><div> </div><div>So in this example TOTAL_COLORS will be equ=
al to 3. However let assume that a new color for example White was added.</=
div><div> </div><div><div>enum { Red, Green, Blue, Black, White, TOTAL=
_COLORS =3D Black };</div><div> </div><div>In this case the value of T=
OTAL_COLORS becames invalid. </div><div>So we need to rewrite the enumerati=
on</div><div> </div><div><div>enum { Red, Green, Blue, Black, White, T=
OTAL_COLORS =3D White };</div><div> </div></div><div>It would be =
good if the value of TOTAL_COLOR will not depend of new added enumerators.<=
/div></div><div> </div><div>It could be done using the following synta=
x</div><div> </div><div><div>enum { Red, Green, Blue, Black, White, TO=
TAL_COLORS =3D * };</div><div> </div><div>where the asterisk (or =
something else) would mean the value of the previous enumerator.<=
/div><div> </div><div></div></div></blockquote><div> </div><div>&=
nbsp;</div><div>I'd like to summarize the main ideas. </div><div> =
;</div><div>To make accessiable the value of the previous enumerator t=
o the current enumerator without referencing the name of the previous =
enumerator. </div><div> </div><div>To make some sort of indexed a=
ccess to values of previous enumerators inside the definition of enume=
rator as for example </div><div> </div><div>enum Color { Red, Blu=
e, Green, Black =3D Color[0] + Color[1] + Color[2] };</div><div> </div=
><blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-=
left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: =
solid;" class=3D"gmail_quote"><div><div></div></div></blockquote></blockquo=
te><div> </div><div>I made a typo. Shall be</div><div> </div><div=
>To make some sort of indexed access to values of previous enumerators insi=
de the definition of an enumeration...</div><div> </div></blockquote><=
div> </div><div> </div><div>By the way the both goals can be achi=
eved by using indexing. For example the value of the previous enumerat=
or can be obtained by using syntax</div><div> </div><div> </div><=
blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-le=
ft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: so=
lid;" class=3D"gmail_quote"><div><div>enum Color { Red =3D 1, Blue =3D 2, G=
reen =3D 4, Black =3D Color[0] | Color[1] | Color[2], TotalC=
olor =3D Color[-1] };</div><div> </div></div></blockquote><div>T=
hat is a negative index will provide the access to previous enumerators.:)&=
nbsp;</div><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><div> </div></div><blockq=
uote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-col=
or: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" =
class=3D"gmail_quote"><blockquote 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;" class=3D"gmail_quote"><div><div> </div></=
div></blockquote></blockquote></blockquote>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_40_11249494.1364981655622--
.
Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Wed, 3 Apr 2013 02:44:36 -0700 (PDT)
Raw View
------=_Part_48_7810474.1364982276289
Content-Type: text/plain; charset=ISO-8859-1
On Wednesday, April 3, 2013 1:34:15 PM UTC+4, Vlad from Moscow wrote:
>
>
> On Wednesday, April 3, 2013 1:23:08 PM UTC+4, Vlad from Moscow wrote:
>>
>>
>> On Wednesday, April 3, 2013 1:18:03 PM UTC+4, Vlad from Moscow wrote:
>>>
>>>
>>> On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wrote:
>>>>
>>>> As an idea. It is not rare that sometimes the last enumerator has to
>>>> have the value of the previous enumerator.
>>>> For example
>>>>
>>>> enum { Red, Green, Blue, Black, TOTAL_COLORS = Black };
>>>>
>>>> So in this example TOTAL_COLORS will be equal to 3. However let assume
>>>> that a new color for example White was added.
>>>>
>>>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = Black };
>>>>
>>>> In this case the value of TOTAL_COLORS becames invalid.
>>>> So we need to rewrite the enumeration
>>>>
>>>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = White };
>>>>
>>>> It would be good if the value of TOTAL_COLOR will not depend of new
>>>> added enumerators.
>>>>
>>>> It could be done using the following syntax
>>>>
>>>> enum { Red, Green, Blue, Black, White, TOTAL_COLORS = * };
>>>>
>>>> where the asterisk (or something else) would mean the value of the
>>>> previous enumerator.
>>>>
>>>>
>>>
>>>
>>> I'd like to summarize the main ideas.
>>>
>>> To make accessiable the value of the previous enumerator to the current
>>> enumerator without referencing the name of the previous enumerator.
>>>
>>> To make some sort of indexed access to values of previous enumerators
>>> inside the definition of enumerator as for example
>>>
>>> enum Color { Red, Blue, Green, Black = Color[0] + Color[1] + Color[2] };
>>>
>>>
>>>>
>> I made a typo. Shall be
>>
>> To make some sort of indexed access to values of previous enumerators
>> inside the definition of an enumeration...
>>
>>
>
>
> By the way the both goals can be achieved by using indexing. For example
> the value of the previous enumerator can be obtained by using syntax
>
>
>
>> enum Color { Red = 1, Blue = 2, Green = 4, Black = Color[0] | Color[1] |
>> Color[2], TotalColor = Color[-1] };
>>
>>
> That is a negative index will provide the access to previous
> enumerators.:)
>
>>
>>
>>>
The proposal (C/C++) can be named as "Indexed access to enumerators inside
the enumeration declaration." :)
>
>>>>
>>>
--
---
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/?hl=en.
------=_Part_48_7810474.1364982276289
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>On Wednesday, April 3, 2013 1:34:15 PM UTC+4, Vlad from Moscow wrote:<b=
lockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;" class=3D"gmail_quote"><br>On Wednesday, April 3, 2013 1:23:08 PM UTC+4=
, Vlad from Moscow wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; pa=
dding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: =
1px; border-left-style: solid;" class=3D"gmail_quote"><br>On Wednesday, Apr=
il 3, 2013 1:18:03 PM UTC+4, Vlad from Moscow wrote:<blockquote style=3D"ma=
rgin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204=
, 204); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_q=
uote"><br>On Wednesday, April 3, 2013 1:53:11 AM UTC+4, Vlad from Moscow wr=
ote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bord=
er-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-styl=
e: solid;" class=3D"gmail_quote"><div>As an idea. It is not rare that somet=
imes the last enumerator has to have the value of the previous enumerator.<=
/div><div>For example</div><div> </div><div>enum { Red, Green, Blue, B=
lack, TOTAL_COLORS =3D Black };</div><div> </div><div>So in this examp=
le TOTAL_COLORS will be equal to 3. However let assume that a new color for=
example White was added.</div><div> </div><div><div>enum { Red, Green=
, Blue, Black, White, TOTAL_COLORS =3D Black };</div><div> </div><div>=
In this case the value of TOTAL_COLORS becames invalid. </div><div>So we ne=
ed to rewrite the enumeration</div><div> </div><div><div>enum { Red, G=
reen, Blue, Black, White, TOTAL_COLORS =3D White };</div><div> </=
div></div><div>It would be good if the value of TOTAL_COLOR will not depend=
of new added enumerators.</div></div><div> </div><div>It could be don=
e using the following syntax</div><div> </div><div><div>enum { Red, Gr=
een, Blue, Black, White, TOTAL_COLORS =3D * };</div><div> </div><=
div>where the asterisk (or something else) would mean the value o=
f the previous enumerator.</div><div> </div><div></div></div></blockqu=
ote><div> </div><div> </div><div>I'd like to summarize the m=
ain ideas. </div><div> </div><div>To make accessiable the value o=
f the previous enumerator to the current enumerator without referencin=
g the name of the previous enumerator. </div><div> </div><div>To =
make some sort of indexed access to values of previous enumerators ins=
ide the definition of enumerator as for example </div><div> </div=
><div>enum Color { Red, Blue, Green, Black =3D Color[0] + Color[1] + Color[=
2] };</div><div> </div><blockquote style=3D"margin: 0px 0px 0px 0.8ex;=
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-widt=
h: 1px; border-left-style: solid;" class=3D"gmail_quote"><div><div></div></=
div></blockquote></blockquote><div> </div><div>I made a typo. Shall be=
</div><div> </div><div>To make some sort of indexed access to values o=
f previous enumerators inside the definition of an enumeration...</div><div=
> </div></blockquote><div> </div><div> </div><div>By the way=
the both goals can be achieved by using indexing. For example the val=
ue of the previous enumerator can be obtained by using syntax</div><div>&nb=
sp;</div><div> </div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
1px; border-left-style: solid;" class=3D"gmail_quote"><div><div>enum Color=
{ Red =3D 1, Blue =3D 2, Green =3D 4, Black =3D Color[0] | Color[1]&n=
bsp;| Color[2], TotalColor =3D Color[-1] };</div><div> </di=
v></div></blockquote><div>That is a negative index will provide the access =
to previous enumerators.:) </div><blockquote style=3D"margin: 0px 0px =
0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border=
-left-width: 1px; border-left-style: solid;" class=3D"gmail_quote"><div><di=
v> </div></div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding=
-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; =
border-left-style: solid;" class=3D"gmail_quote"><blockquote style=3D"margi=
n: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 2=
04); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_quot=
e"><div><div></div></div></blockquote></blockquote></blockquote></blockquot=
e><div> </div><div> </div><div>The proposal (C/C++) can be named =
as "Indexed access to enumerators inside the enumeration declaration." :)&n=
bsp;</div><blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex=
; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-lef=
t-style: solid;" class=3D"gmail_quote"><blockquote style=3D"margin: 0px 0px=
0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); borde=
r-left-width: 1px; border-left-style: solid;" class=3D"gmail_quote"><blockq=
uote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-col=
or: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" =
class=3D"gmail_quote"><blockquote 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;" class=3D"gmail_quote"><div><div> </div></=
div></blockquote></blockquote></blockquote></blockquote>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_48_7810474.1364982276289--
.
Author: Shakti Misra <shakti.misra.study@gmail.com>
Date: Wed, 3 Apr 2013 15:23:28 +0530
Raw View
--089e0160c9be67cfae04d971d38e
Content-Type: text/plain; charset=ISO-8859-1
for E{a,b=4}; it should return 2. E.size is the total number of elements in
it. . may be .size is not a good name. But thats the idea
--
---
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/?hl=en.
--089e0160c9be67cfae04d971d38e
Content-Type: text/html; charset=ISO-8859-1
<div dir="ltr">for E{a,b=4}; it should return 2. E.size is the total number of elements in it. . may be .size is not a good name. But thats the idea<br></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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en">http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en</a>.<br />
<br />
<br />
--089e0160c9be67cfae04d971d38e--
.
Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Wed, 3 Apr 2013 12:05:21 +0200
Raw View
On Wed, Apr 3, 2013 at 11:53 AM, Shakti Misra
<shakti.misra.study@gmail.com> wrote:
> for E{a,b=4}; it should return 2. E.size is the total number of elements in
> it. . may be .size is not a good name. But thats the idea
Ok, I don't think that definition of .size is useful without a way to
list the enumerators, which likely has to wait until the reflection
group figures out where they're going. On the other hand, I do know of
uses for ways to get the minimum and maximum enumerators, and the
minimum and maximum values ([dcl.enum]p7) in the enumeration type.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Wed, 03 Apr 2013 13:17:05 +0200
Raw View
Le 02/04/13 23:53, Vlad from Moscow a =E9crit :
> As an idea. It is not rare that sometimes the last enumerator has to=20
> have the value of the previous enumerator.
> For example
> enum { Red, Green, Blue, Black, TOTAL_COLORS =3D Black };
> So in this example TOTAL_COLORS will be equal to 3. However let assume=20
> that a new color for example White was added.
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D Black };
> In this case the value of TOTAL_COLORS becames invalid.
> So we need to rewrite the enumeration
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D White };
> It would be good if the value of TOTAL_COLOR will not depend of new=20
> added enumerators.
> It could be done using the following syntax
> enum { Red, Green, Blue, Black, White, TOTAL_COLORS =3D * };
> where the asterisk (or something else) would mean the value of the=20
> previous enumerator.
>
For this kind of enumerations I would prefer something less dangerous as=20
a size operation that works only if the enumerations have all different=20
values.
enum E { Red, Green, Blue, Black, White };
E::size()
or
size<E>()
Maybe we need a specific kind of ordinal enumerations. (See my request=20
for interest on ordinal enums).
Vicente
--=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/?hl=3Den.
.
Author: =?UTF-8?Q?R=C3=B3bert_D=C3=A1vid?= <lrdxgm@gmail.com>
Date: Wed, 3 Apr 2013 15:13:58 -0700 (PDT)
Raw View
------=_Part_315_29055842.1365027238636
Content-Type: text/plain; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
2013. =E1prilis 3., szerda 10:58:05 UTC+2 id=F5pontban Daniel Kr=FCgler a=
=20
k=F6vetkez=F5t =EDrta:
>
>
> Technically this would be possible, but generally library solutions are a=
=20
> preferred approach, if they can realize the same thing. It is much more=
=20
> costly to modify the core language instead of modifying the standard=20
> library.
>
> - Daniel
>
>
> I second this. We already have a few stuff at around <type_traits> that=
=20
cannot be implemented without compiler intrinsics, what can a few more of=
=20
such STL classes hurt? :)
If I understand the problem correctly, what Vlad needs in the original post=
=20
is a std::enum_traits<Color>::max_value.
Checking around the rest of the posts, taming the core language extension=
=20
ideas into a library solution:
namespace std {
template< typename E >
struct enum_traits {
private:
typedef underlying_type<E>::type ut;
public:
static const E min_value =3D ..; //=
smallest=20
value
static const E max_value =3D ..; //=
largest=20
value
template<utype i> struct enumof { static const E value =3D ..; }; //=
"index"=20
-> enum
template<E value> struct indexof { static const utype value =3D ..; }; //=
enum=20
-> "index"
template<utype i> constexpr to_enum () { return static_cast<E >(i )=
;=20
} //enum -> value
template<E value> constexpr to_value() { return static_cast<utype>(value)=
;=20
} //value -> enum
//add more
};
}
enum Color { Red, Green, Blue, Black, White };
void foo() {
typedef std::enum_traits<Color> colorTraits;
Color a =3D colorTraits::min_value; // =3D=3D Red
Color b =3D colorTraits::max_value; // =3D=3D White
Color c =3D colorTraits::enumof<2>::value; // =3D=3D Blue
int x =3D colorTraits::indexof<Green>::value; // =3D=3D 1
}
What I would add to the list (unrelated to the other ideas here), is a=20
convenient way to enumerate enums (funny..):
for( MyEnum e : std::enum_traits<MyEnum>::enumerate )
{ /* do stuff */ }
Might be even implementable without intrinsics. Allowing to use previous=20
enum values inside the definition of the enum.. I.. don't really see the=20
point, I'd skip that.
Regards,
Robert=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/?hl=3Den.
------=_Part_315_29055842.1365027238636
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<br><br>2013. =E1prilis 3., szerda 10:58:05 UTC+2 id=F5pontban Daniel Kr=FC=
gler a k=F6vetkez=F5t =EDrta:<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"><div><br></div><div>Technically this would be possible, but=
generally library solutions are a preferred approach, if they can realize =
the same thing. It is much more costly to modify the core language instead =
of modifying the standard library.<br>
<br></div><div>- Daniel<br><br></div><div><br></div></div></blockquote><div=
>I second this. We already have a few stuff at around <type_traits> t=
hat cannot be implemented without compiler intrinsics, what can a few more =
of such STL classes hurt? :)<br><br>If I understand the problem correctly, =
what Vlad needs in the original post is a std::enum_traits<Color>::ma=
x_value.<br>Checking around the rest of the posts, taming the core language=
extension ideas into a library solution:<br><br><span style=3D"font-family=
: courier new,monospace;"><div class=3D"prettyprint" style=3D"background-co=
lor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: so=
lid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">namespace</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> std </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> E </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> enum_traits </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">private</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">typedef</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
underlying_type</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify"><</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
E</span><span style=3D"color: #660;" class=3D"styled-by-prettify">>::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">type ut</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">static</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> E min_value </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">..;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
&nbs=
p; </span><span style=3D"color: #=
800;" class=3D"styled-by-prettify">//smallest value</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">static</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">const</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> E max_value </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">=3D</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-pretti=
fy"> =
</span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">//largest value</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">utype i</span><span styl=
e=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">struct</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> enumof </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">static</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> E =
value </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">..;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//"index" -> enum</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">E value</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> indexof </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>static</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> utype value </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">..;</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"style=
d-by-prettify">//enum -> "index"</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br> </span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">template</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"><</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">utype i</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">constexpr</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> to_enum </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">static_cast</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">E </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">>(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">i </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">}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//e=
num -> value</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">template</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">E value</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>></span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> to_value</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">static_cast</span><span style=3D"color: #080;" class=3D"styled-b=
y-prettify"><utype></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">value</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">//value -> enum</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br><br> </span><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">//add more</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">enum</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Color</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #606;" class=3D"styled-by-prettify">Red</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: #606;" =
class=3D"styled-by-prettify">Green</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">Blue</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: #606;" class=3D"styled-by-prettify">Black</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: #6=
06;" class=3D"styled-by-prettify">White</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-b=
y-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">typedef</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> 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">enum_traits</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><</span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">Color</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> colorTraits</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br> </span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Color</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> colorT=
raits</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">min_value</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> &=
nbsp; </span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">// =3D=3D Red</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br> </span><span style=3D"color: #606;" class=3D"styled=
-by-prettify">Color</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> b </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> colo=
rTraits</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">max_value</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">// =3D=3D White</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br> </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Color</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> c </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
colorTraits</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">enumof<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">>::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">value</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// =3D=3D Blue</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> colorTraits</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">indexof</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">Green</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">>::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">value</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: #800;" class=3D"styled-by-prettify">// =3D=3D 1<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></=
div><br><span style=3D"font-family: arial,sans-serif;">What I would add to =
the list (unrelated to the other ideas here), is a convenient way to enumer=
ate enums (funny..):<br><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"prettyprin=
t"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">for</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">MyEnum</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> e </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">enum_traits</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><</span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">MyEnum</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">>::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">enumerate </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">/* do stuff *=
/</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></d=
iv><br></span></span><span style=3D"font-family: arial,sans-serif;">Might b=
e even implementable without intrinsics. Allowing to use previous enum valu=
es inside the definition of the enum.. I.. don't really see the point, I'd =
skip that.</span><br><br>Regards,<br>Robert <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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
------=_Part_315_29055842.1365027238636--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 04 Apr 2013 01:38:54 +0200
Raw View
This is a multi-part message in MIME format.
--------------030301070302090301060000
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 04/04/13 00:13, R=F3bert D=E1vid a =E9crit :
>
>
> 2013. =E1prilis 3., szerda 10:58:05 UTC+2 id=F5pontban Daniel Kr=FCgler a=
=20
> k=F6vetkez=F5t =EDrta:
>
>
> Technically this would be possible, but generally library
> solutions are a preferred approach, if they can realize the same
> thing. It is much more costly to modify the core language instead
> of modifying the standard library.
>
> - Daniel
>
>
> I second this. We already have a few stuff at around <type_traits>=20
> that cannot be implemented without compiler intrinsics, what can a few=20
> more of such STL classes hurt? :)
>
> If I understand the problem correctly, what Vlad needs in the original=20
> post is a std::enum_traits<Color>::max_value.
> Checking around the rest of the posts, taming the core language=20
> extension ideas into a library solution:
>
> |
> namespacestd {
> template<typenameE >
> structenum_traits {
> private:
> typedefunderlying_type<E>::type ut;
> public:
> staticconstE min_value =3D..;//smallest value
> staticconstE max_value =3D..;//largest value
> template<utype i>structenumof {staticconstE value =3D..;};//"index" -> en=
um
> template<E value>structindexof {staticconstutype value =3D..;};//enum ->=
=20
> "index"
>
> template<utype i>constexprto_enum (){returnstatic_cast<E >(i );}//enum=20
> -> value
> template<E=20
> value>constexprto_value(){returnstatic_cast<utype>(value);}//value -> enu=
m
>
> //add more
> };
> }
>
> enumColor{Red,Green,Blue,Black,White};
>
> voidfoo(){
> typedefstd::enum_traits<Color>colorTraits;
> Colora =3DcolorTraits::min_value;// =3D=3D Red
> Colorb =3DcolorTraits::max_value;// =3D=3D White
> Colorc =3DcolorTraits::enumof<2>::value;// =3D=3D Blue
> intx =3DcolorTraits::indexof<Green>::value;// =3D=3D 1
> }
> |
>
> What I would add to the list (unrelated to the other ideas here), is a=20
> convenient way to enumerate enums (funny..):
>
> |
> for(MyEnume :std::enum_traits<MyEnum>::enumerate )
> {/* do stuff */}
> |
>
> Might be even implementable without intrinsics. Allowing to use=20
> previous enum values inside the definition of the enum.. I.. don't=20
> really see the point, I'd skip that.
>
>
Hi, the approach I take in Boost.Enums=20
(https://svn.boost.org/svn/boost/sandbox/enums/libs/enums/doc/html/index.ht=
ml#boost.enums.users_guide.tutorial.ordinal)=20
was to have separated traits.
The traits where the compiler could help the user are:
* |size|: the number of elements in the enum type.
* |pos|: the position relative of an element in the enum type.
* |val|: the element in the enum type at a given position.
boost::enums::meta::size<EC>::value
boost::enums::meta::pos<EC, V>::value
boost::enums::meta::val<EC, P>::value
Once we have this either given by the compiler or by the user (by=20
specialization), a library can provide much more, enum sets, enum=20
arrays, enum ranges, ...
Vicente
--=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/?hl=3Den.
--------------030301070302090301060000
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DISO-8859-2"
http-equiv=3D"Content-Type">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 04/04/13 00:13, R=F3bert D=E1vid a
=E9crit=A0:<br>
</div>
<blockquote
cite=3D"mid:d28f46df-3af3-4c37-acd1-4b7eb639a2ef@isocpp.org"
type=3D"cite"><br>
<br>
2013. =E1prilis 3., szerda 10:58:05 UTC+2 id=F5pontban Daniel Kr=FCgl=
er
a k=F6vetkez=F5t =EDrta:
<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><br>
</div>
<div>Technically this would be possible, but generally library
solutions are a preferred approach, if they can realize the
same thing. It is much more costly to modify the core
language instead of modifying the standard library.<br>
<br>
</div>
<div>- Daniel<br>
<br>
</div>
<div><br>
</div>
</div>
</blockquote>
<div>I second this. We already have a few stuff at around
<type_traits> that cannot be implemented without compiler
intrinsics, what can a few more of such STL classes hurt? :)<br>
<br>
If I understand the problem correctly, what Vlad needs in the
original post is a std::enum_traits<Color>::max_value.<br>
Checking around the rest of the posts, taming the core language
extension ideas into a library solution:<br>
<br>
<span style=3D"font-family: courier new,monospace;">
<div class=3D"prettyprint" style=3D"background-color: rgb(250,
250, 250); border-color: rgb(187, 187, 187); border-style:
solid; border-width: 1px; word-wrap: break-word;"><code
class=3D"prettyprint">
<div class=3D"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">namespace</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> std =
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">typen=
ame</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> E </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">><=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">struct</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
enum_traits </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">private</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">:</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">typedef</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
underlying_type</span><span style=3D"color: #660;"
class=3D"styled-by-prettify"><</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">E</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">>:=
:</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">type
ut</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">;</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">public</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">:</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #000;"
class=3D"styled-by-prettify">=A0 </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">stati=
c</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> E
min_value </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or:
#000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #660;" class=3D"styled-by-prettify">..;</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> =A0 =
=A0 =A0
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 </span><span
style=3D"color: #800;" class=3D"styled-by-prettify">//sma=
llest
value</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">static</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> E
max_value </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or:
#000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #660;" class=3D"styled-by-prettify">..;</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> =A0 =
=A0 =A0
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 </span><span
style=3D"color: #800;" class=3D"styled-by-prettify">//lar=
gest
value</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">utype
i</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">></span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">struc=
t</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
enumof =A0</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">stati=
c</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> E =
=A0 =A0
value </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or:
#000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #660;" class=3D"styled-by-prettify">..;</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #800;" class=3D"styled-by-prettify">//"in=
dex"
-> enum</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">E
value</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">></span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">struc=
t</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
indexof </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #008;" class=3D"styled-by-prettify">stati=
c</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> utyp=
e
value </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or:
#000;" class=3D"styled-by-prettify"> </span><span
style=3D"color: #660;" class=3D"styled-by-prettify">..;</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #800;" class=3D"styled-by-prettify">//enu=
m
-> "index"</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
<br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">utype
i</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">></span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">const=
expr</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
to_enum </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">()</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">stati=
c_cast</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">E =A0=
=A0</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">>(=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">i =A0=
=A0</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">}</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #800;" class=3D"styled-by-prettify">//enu=
m
=A0-> value</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">E
value</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">></span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">const=
expr</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
to_value</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">()</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">stati=
c_cast</span><span
style=3D"color: #080;" class=3D"styled-by-prettify"><u=
type></span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify">value=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">);</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">}</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #800;" class=3D"styled-by-prettify">//val=
ue
-> enum</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
<br>
=A0 </span><span style=3D"color: #800;"
class=3D"styled-by-prettify">//add more</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">};</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">}</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
<br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">enum</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Color=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Red</=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Green=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Blue<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Black=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">White=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
<br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">void</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> foo<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">()</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">typedef</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> std<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify">enum_=
traits</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Color=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">><=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
colorTraits</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">;</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #606;"
class=3D"styled-by-prettify">Color</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> a </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
colorTraits</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">::</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">min_v=
alue</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> =A0 =
=A0 =A0
=A0 =A0 =A0 </span><span style=3D"color: #800;"
class=3D"styled-by-prettify">// =3D=3D Red</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #606;"
class=3D"styled-by-prettify">Color</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> b </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
colorTraits</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">::</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">max_v=
alue</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> =A0 =
=A0 =A0
=A0 =A0 =A0 </span><span style=3D"color: #800;"
class=3D"styled-by-prettify">// =3D=3D White</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #606;"
class=3D"styled-by-prettify">Color</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> c </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
colorTraits</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">::</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">enumo=
f</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #066;" class=3D"styled-by-prettify">2</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">>:=
:</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">value=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> =A0 =
=A0 =A0</span><span
style=3D"color: #800;" class=3D"styled-by-prettify">// =
=3D=3D
Blue</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">int</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> x </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> =A0
colorTraits</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">::</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">index=
of</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Green=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">>:=
:</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">value=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #800;" class=3D"styled-by-prettify">// =
=3D=3D
1</span><span style=3D"color: #000;"
class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">}</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
</span></div>
</code></div>
<br>
<span style=3D"font-family: arial,sans-serif;">What I would add
to the list (unrelated to the other ideas here), is a
convenient way to enumerate enums (funny..):<br>
<br>
<div class=3D"prettyprint" style=3D"background-color: rgb(250,
250, 250); border-color: rgb(187, 187, 187); border-style:
solid; border-width: 1px; word-wrap: break-word;"><code
class=3D"prettyprint">
<div class=3D"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">for</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span
style=3D"color: #606;" class=3D"styled-by-prettify">MyE=
num</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> e =
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">:</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> st=
d</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">enu=
m_traits</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><=
;</span><span
style=3D"color: #606;" class=3D"styled-by-prettify">MyE=
num</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">>=
;::</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">enu=
merate
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">)</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>
</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: #800;" class=3D"styled-by-prettify">/*
do stuff */</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></div>
</code></div>
<br>
</span></span><span style=3D"font-family: arial,sans-serif;">Migh=
t
be even implementable without intrinsics. Allowing to use
previous enum values inside the definition of the enum.. I..
don't really see the point, I'd skip that.</span><br>
<br>
</div>
<br>
</blockquote>
Hi, the approach I take in Boost.Enums
(<a class=3D"moz-txt-link-freetext" href=3D"https://svn.boost.org/svn/b=
oost/sandbox/enums/libs/enums/doc/html/index.html#boost.enums.users_guide.t=
utorial.ordinal">https://svn.boost.org/svn/boost/sandbox/enums/libs/enums/d=
oc/html/index.html#boost.enums.users_guide.tutorial.ordinal</a>)
was to have separated traits.=A0 <br>
The traits where the compiler could help the user are:<br>
<div class=3D"itemizedlist">
<ul class=3D"itemizedlist" type=3D"disc">
<li class=3D"listitem"> <code class=3D"computeroutput"><span
class=3D"identifier">size</span></code>: the number of
elements in the enum type. </li>
<li class=3D"listitem"> <code class=3D"computeroutput"><span
class=3D"identifier">pos</span></code>: the position
relative of an element in the enum type. </li>
<li class=3D"listitem"> <code class=3D"computeroutput"><span
class=3D"identifier">val</span></code>: the element in the
enum type at a given position. </li>
</ul>
</div>
<pre class=3D"programlisting"><span class=3D"identifier">boost</span><s=
pan class=3D"special">::</span><span class=3D"identifier">enums</span><span=
class=3D"special">::</span><span class=3D"identifier">meta</span><span cla=
ss=3D"special">::</span><span class=3D"identifier">size</span><span class=
=3D"special"><</span><span class=3D"identifier">EC</span><span class=3D"=
special">>::</span><span class=3D"identifier">value</span>
<span class=3D"identifier">boost</span><span class=3D"special">::</span><sp=
an class=3D"identifier">enums</span><span class=3D"special">::</span><span =
class=3D"identifier">meta</span><span class=3D"special">::</span><span clas=
s=3D"identifier">pos</span><span class=3D"special"><</span><span class=
=3D"identifier">EC</span><span class=3D"special">,</span> <span class=3D"id=
entifier">V</span><span class=3D"special">>::</span><span class=3D"ident=
ifier">value</span>
<span class=3D"identifier">boost</span><span class=3D"special">::</span><sp=
an class=3D"identifier">enums</span><span class=3D"special">::</span><span =
class=3D"identifier">meta</span><span class=3D"special">::</span><span clas=
s=3D"identifier">val</span><span class=3D"special"><</span><span class=
=3D"identifier">EC</span><span class=3D"special">,</span> <span class=3D"id=
entifier">P</span><span class=3D"special">>::</span><span class=3D"ident=
ifier">value
</span></pre>
Once we have this either given by the compiler or by the user (by
specialization), a library can provide much more, enum sets, enum
arrays, enum ranges, ...<br>
<br>
Vicente<br>
<br>
<br>
</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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
<br />
<br />
--------------030301070302090301060000--
.
Author: Lawrence Crowl <crowl@googlers.com>
Date: Thu, 4 Apr 2013 16:12:26 -0700
Raw View
On 4/3/13, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
> * |size|: the number of elements in the enum type.
> * |pos|: the position relative of an element in the enum type.
> * |val|: the element in the enum type at a given position.
Enumerations are used for different purposes, and there is no one
size suited to all purposes.
In particular,
enum flags { first = 1, second = 2, third = 4 };
enum ages { infant, toddler, juvenile, adolecent, adult };
For flags, you want the minimum and maximum values permitted by
the standard, 0 and 7, respectively.
For ages, you want the minimum and maximum values for the listed
enumerators, 0 and 5, respectively.
The 'size' only make sense for enums used like ages, i.e. like
Pascal enums.
--
Lawrence Crowl
--
---
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/?hl=en.
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 05 Apr 2013 08:38:17 +0200
Raw View
Le 05/04/13 01:12, Lawrence Crowl a =E9crit :
> On 4/3/13, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
>> * |size|: the number of elements in the enum type.
>> * |pos|: the position relative of an element in the enum type.
>> * |val|: the element in the enum type at a given position.
> Enumerations are used for different purposes, and there is no one
> size suited to all purposes.
>
> In particular,
>
> enum flags { first =3D 1, second =3D 2, third =3D 4 };
> enum ages { infant, toddler, juvenile, adolecent, adult };
>
> For flags, you want the minimum and maximum values permitted by
> the standard, 0 and 7, respectively.
>
> For ages, you want the minimum and maximum values for the listed
> enumerators, 0 and 5, respectively.
>
> The 'size' only make sense for enums used like ages, i.e. like
> Pascal enums.
>
You are completely right. This is why I was talking in my original post=20
of *ordinal types*, to make the difference.
If flags is an ordinal type
'ordinal' enum flags { first =3D 1, second =3D 2, third =3D 4 };
you shouldn't be able to do
flags f =3D first | second;
you should need to use an ordinal set
ordinal_set<flags> f =3D first | second;
As Kevlin Henney explained in is paper "Flags waiving", making the=20
difference between the elements and the container is important.
It is worth introducing these kind of ordinal types in C++?
[1] (http://www.two-sdg.demon.co.uk/curbralan/papers/FlagWaiving.pdf)
Best,
Vicente
--=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/?hl=3Den.
.
Author: Lawrence Crowl <crowl@googlers.com>
Date: Mon, 8 Apr 2013 16:36:00 -0700
Raw View
On 4/4/13, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
> Le 05/04/13 01:12, Lawrence Crowl a =E9crit :
>> On 4/3/13, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
>>> * |size|: the number of elements in the enum type.
>>> * |pos|: the position relative of an element in the enum type.
>>> * |val|: the element in the enum type at a given position.
>> Enumerations are used for different purposes, and there is no one
>> size suited to all purposes.
>>
>> In particular,
>>
>> enum flags { first =3D 1, second =3D 2, third =3D 4 };
>> enum ages { infant, toddler, juvenile, adolecent, adult };
>>
>> For flags, you want the minimum and maximum values permitted by
>> the standard, 0 and 7, respectively.
>>
>> For ages, you want the minimum and maximum values for the listed
>> enumerators, 0 and 5, respectively.
>>
>> The 'size' only make sense for enums used like ages, i.e. like
>> Pascal enums.
>>
> You are completely right. This is why I was talking in my original post
> of *ordinal types*, to make the difference.
>
> If flags is an ordinal type
>
> 'ordinal' enum flags { first =3D 1, second =3D 2, third =3D 4 };
>
> you shouldn't be able to do
>
> flags f =3D first | second;
>
> you should need to use an ordinal set
>
> ordinal_set<flags> f =3D first | second;
>
> As Kevlin Henney explained in is paper "Flags waiving", making the
> difference between the elements and the container is important.
>
> It is worth introducing these kind of ordinal types in C++?
I think so, but I don't have time to do the proposal.
>
> [1] (http://www.two-sdg.demon.co.uk/curbralan/papers/FlagWaiving.pdf)
--=20
Lawrence Crowl
--=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/?hl=3Den.
.