Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++.moderated > #1831
| Message-ID | <2011081706332351646-pete@versatilecodingcom> (permalink) |
|---|---|
| Newsgroups | comp.lang.c++.moderated, comp.std.c++, comp.lang.c++ |
| From | Pete Becker <pete@versatilecoding.com> |
| Subject | Re: New strongly type enum proposal featuring inherited enums |
| Organization | Roundhouse Consulting, Ltd. |
| References | <4e49ea26$2@news.x-privat.org> |
| Date | 2011-08-18 07:51 -0600 |
Cross-posted to 3 groups.
On 2011-08-16 21:28:17 +0000, Phil Bouchard said:
> Hi,
>
> Is it too late to change the strongly type enum?
Yes, C++11 has been unanimously approved. It will be an official
standard in a few weeks.
No, work is just starting on the next version of the C++ standard.
> I have a proposal
> that is much cleaner than what is on its way.
>
> Right now we have:
> enum class Val: unsigned long { E1, E2, E3, E4 };
>
> Comments:
> 1) This design is bad because the ':' sign is reserved for inheritance.
Really? Where does the standard say that it's "reserved"? <g>
It's currently used to indicate inheritance, to separate two
expressions in a ternary operator, and to mark the size of a bitfield.
>
> 2) Inheriting from another enum would be quite useful. For example:
> enum class Widget {button, combobox, listview};
> enum class SuperWidget : Widget {iconview}
>
> This way iconview would be equal to 3, not 0.
Sure. That's not precluded by using ':' to indicate that an enum is
based on an integral type.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.lang.c++.moderated | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
New strongly type enum proposal featuring inherited enums Phil Bouchard <philippe@fornux.com> - 2011-08-16 21:28 -0600 Re: New strongly type enum proposal featuring inherited enums Daniel Krügler <daniel.kruegler@googlemail.com> - 2011-08-18 07:54 -0600 Re: New strongly type enum proposal featuring inherited enums Pete Becker <pete@versatilecoding.com> - 2011-08-18 07:51 -0600 Re: New strongly type enum proposal featuring inherited enums Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-08-18 07:53 -0600 Re: New strongly type enum proposal featuring inherited enums Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-18 07:52 -0600
csiph-web