Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #8967

New strongly type enum proposal featuring inherited enums

Message-ID <4e49ea26$2@news.x-privat.org> (permalink)
Newsgroups comp.std.c++, comp.lang.c++, comp.lang.c++.moderated
From Phil Bouchard <philippe@fornux.com>
Subject New strongly type enum proposal featuring inherited enums
Organization X-Privat.Org NNTP Server - http://www.x-privat.org
Date 2011-08-16 21:28 -0600

Cross-posted to 3 groups.

Show all headers | View raw


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.

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;


Thanks,
-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                      ]

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


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 Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-17 08:16 -0400
    Re: New strongly type enum proposal featuring inherited enums Phil Bouchard <philippe@fornux.com> - 2011-08-17 14:25 -0400
      Re: New strongly type enum proposal featuring inherited enums "Bo Persson" <bop@gmb.dk> - 2011-08-18 14:32 +0200
    Re: New strongly type enum proposal featuring inherited enums Fred <fred.l.kleinschmidt@boeing.com> - 2011-08-17 11:31 -0700
      Re: New strongly type enum proposal featuring inherited enums "Bo Persson" <bop@gmb.dk> - 2011-08-18 14:30 +0200
    Re: New strongly type enum proposal featuring inherited enums Phil Bouchard <philippe@fornux.com> - 2011-08-17 18:01 -0400
      Re: New strongly type enum proposal featuring inherited enums Marc <marc.glisse@gmail.com> - 2011-08-17 23:16 +0000
        Re: New strongly type enum proposal featuring inherited enums Marc <marc.glisse@gmail.com> - 2011-08-17 23:19 +0000
        Re: New strongly type enum proposal featuring inherited enums Phil Bouchard <philippe@fornux.com> - 2011-08-18 00:07 -0400
  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