Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Phil Bouchard Newsgroups: comp.std.c++ Subject: Re: New strongly type enum proposal featuring inherited enums Date: Wed, 24 Aug 2011 14:52:05 -0700 (PDT) Organization: albasani.net Lines: 35 Sender: std-cpp-request@vandevoorde.com Approved: stephen.clamage@oracle.com Message-ID: <4e4d4889$1@news.x-privat.org> References: <4e49ea26$2@news.x-privat.org> <8739gz7pua.fsf@dpt-info.u-strasbg.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Trace: news.albasani.net cjW9Pg39D1EktptiFr5JDxYQpCUwatPJW9kzxgtiAm6LoPLwQEGZubXPBdYVo8H+LdIgKw0QDc5y5MKocdStvA== NNTP-Posting-Date: Wed, 24 Aug 2011 21:52:06 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="Yaj/z/iWdBBmZUFiXjJ9XTrSkxuBRj/3ZwpCh2ve3Jvh9uQz3v+jRRvyhx8rxwMx/UTqx78PSOLAsTsxjUt4F/JkGVuGwVmqjwyNjGX/Ah42HPqDhVLmlYEYDr0CAgoA"; mail-complaints-to="abuse@albasani.net" X-Mailer: Perl5 Mail::Internet v2.05 X-Submission-Address: std-cpp-submit@vandevoorde.com Cancel-Lock: sha1:Kuz01sySj/9nCE0sm+sysCKQ9IQ= X-Original-Date: Thu, 18 Aug 2011 13:14:50 -0400 Xref: x330-a1.tempe.blueboxinc.net comp.std.c++:244 On 8/18/2011 9:53 AM, Alain Ketterlin wrote: > >> 2) Inheriting from another enum would be quite useful. For example: >> enum class Widget {button, combobox, listview}; >> enum class SuperWidget : Widget {iconview} > > This contradicts with the meaning of sub-typing, which is restriction, > and which you use here as augmentation. Assigning a value of type > SuperWidget to a variable of type Widget would be forbidden, if I > understand your example correctly. The exact opposite of what happens > between a sub-class and its base-class. Exactly. >> 3) Redefining the underlying type could be easily done with: >> enum class Val { unsigned long E1, E2, E3, E4 }; >> >> This is much more neat and is similar to a declaration of multiple instances: >> const unsigned long E1, E2, E3, E4; > > In my opinion, this looks much like a list of members. I know, unions do > this already, but there's "class" in the type declaration here. That's what it is, a list of constant members: const unsigned long E1 = 0, E2 = 1, E3 = 2, E4 = 3; -Phil -- [ 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 ]