Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!news.glorb.com!postnews.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 25 Aug 2011 21:00:08 -0500 Return-Path: Sender: std-cpp-request@vandevoorde.com Approved: stephen.clamage@oracle.com Message-ID: Newsgroups: comp.std.c++ From: Bart van Ingen Schenau Subject: Re: New strongly type enum proposal featuring inherited enums Organization: No organisation in particular References: <4e49ea26$2@news.x-privat.org> Content-Type: text/plain X-Original-Date: Thu, 25 Aug 2011 10:52:34 +0200 X-Submission-Address: std-cpp-submit@vandevoorde.com To: undisclosed-recipients:; Date: Thu, 25 Aug 2011 20:51:07 CST Lines: 63 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-jSueofcbpZRHajSPv2oX5OXIWHAytdnRxWj8aOA4l/dbLHYbhFfU+HayKy/lPTeuam3k588daSFN+VT!WN1LoHbdfphPGWOqia8BwRBZTlowEC5AUdq+XfFW5QeH6o4y30TE4/P6x32kYg== X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3887 Xref: x330-a1.tempe.blueboxinc.net comp.std.c++:257 Daniel Krügler Wrote: > Am 24.08.2011 23:06, schrieb Phil Bouchard: > > On 8/18/2011 9:54 AM, Daniel Krügler wrote: > >> > >>> 2) Inheriting from another enum would be quite useful. For > example: > >>> enum class Widget {button, combobox, listview}; > >>> enum class SuperWidget : Widget {iconview} > >> > >> The current state would not disallow such an extension in the > future, > >> so what is the problem? > > > > I don't think it'll be a good idea to make the two coexist > together: > > enum class SuperWidget : Widget {iconview} // derived > > enum class SuperWidget : unsigned int {iconview} // subtyping > > I'm missing the rationale for your dislike. Widget is still a type that > has an integral type as underlying type, so what is the drastic > difference, if you extend scoped enums to allow for extending > another enum? We have no enumeration values in integral types, so > we have we don't have an observable difference. If you want to > define that SuperWidget contains the enumeration values of > Widget, this is simply a definition problem. The dislike probably comes from how an enum is typically viewed. To my knowledge, an enum is typically viewed as an integer with a limited set of possible values (that some/most of those values also have a symbolic name is incidental). A scoped enum gives you the added value of being able to specify the underlying storage. With this view the interpretation of the declarations would be: enum class Widget : unsigned int { list_view, box, button }; /* RESTRICT a storage cell of size unsigned int to store only the specified values */ enum class SuperWidget : Widget { iconview }; /* EXTEND? the allowed values to include iconview */ OTOH, you seem to view a (scoped) enum as its base-type with some of the values given a symbolic name: enum class Widget : unsigned int { list_view, box, button }; /* Can store all values of an unsigned int, with three of them given a specific, symbolic, name */ enum class SuperWidget : Widget { iconview }; /* Extend the list of symbolic names to include iconview */ > > Greetings from Bremen, > > - Daniel Krügler Bart v Ingen Schenau -- [ 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 ]