Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: red floyd Newsgroups: comp.std.c++ Subject: Re: New strongly type enum proposal featuring inherited enums Date: Wed, 24 Aug 2011 14:06:50 -0700 (PDT) Organization: albasani.net Lines: 39 Sender: std-cpp-request@vandevoorde.com Approved: stephen.clamage@oracle.com Message-ID: References: <4e49ea26$2@news.x-privat.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Trace: news.albasani.net 676BKzXDGY0XdmvlcX/nrNrFxazaXyHp6UMFAI+ZR74oJ3NyP3gc1FSVeELIISBNctdYYtUB9eSM3EnHehAmsQ== NNTP-Posting-Date: Wed, 24 Aug 2011 21:06:59 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="foFECUfNfUdwxXMNCbGA5vSnVy4/dvi67Ze8CEA4Qg0+ARKUEiKIbPuAXVoLB0yLyfZbgW/S1pYTBpPKNOUWgCNGlGtboxd0ZB6mEE4HzBvitmow6XwqKKYEg618V7iZ"; mail-complaints-to="abuse@albasani.net" X-Mailer: Perl5 Mail::Internet v2.05 X-Submission-Address: std-cpp-submit@vandevoorde.com Cancel-Lock: sha1:PTmjeItmo/NA0jdYjgKHqTCyiDU= X-Original-Date: Tue, 16 Aug 2011 20:07:54 -0700 Xref: x330-a1.tempe.blueboxinc.net comp.std.c++:238 On 8/16/2011 8:28 PM, Phil Bouchard wrote: > > Hi, > > Is it too late to change the strongly type enum? I have a proposal > that is much cleaner than what is on its way. Considering that the Standard just got approved, yeah, I'd guess it's probably too late. [grin] > 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. > > 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. > > 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; An interesting proposal. -- [ 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 ]