From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,ab1d177a5a26577d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!novia!news-out.readnews.com!postnews7.readnews.com!not-for-mail Date: Thu, 17 Feb 2011 14:34:21 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What's wrong with C++? References: <1ee1a434-4048-48f6-9f5e-d8126bebb808@r19g2000prm.googlegroups.com> <4D5C1824.3020509@obry.net> <21443638-5ec6-49d4-aafe-6fbc1e59daba@r19g2000prm.googlegroups.com> <87d2371e-af91-4d6a-8d5b-3ddb972d84fd@k17g2000pre.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4d5d7840$0$17330$882e7ee2@usenet-news.net> NNTP-Posting-Host: 1330358c.usenet-news.net X-Trace: DXC=_5Gmi8k=SX2kB9I=nb1[5?QFZ3T]GPM]7mX0AG3X_jU?iEKWiPgeB15VjKk:Lk^BN1cR12TN^Bg7>:KNd2lZeh5 On 2/17/2011 1:48 PM, Yannick DuchĂȘne (Hibou57) wrote: > Le Wed, 16 Feb 2011 21:07:02 +0100, Hyman Rosen a Ă©crit: >> This is legal C++: >> >> struct DamageType { >> enum E { Fire = 1, Acid = 2, Lightning = 4, Poison = 8 }; >> }; >> >> DamageType::E what_my_dragon_can_do = >> DamageType::E( DamageType::Acid | DamageType::Poison ); > > I forget C++ for long I am not aware of its updates since this time. > Does what you wrote mean C++ can restict the possible value of an > enumeration ? Can derive subsets ? The standard says in 7.2/6: For an enumeration where emin is the smallest enumerator and emax is the largest, the values of the enumeration are the values of the underlying type in the range bmin to bmax, where bmin and bmax are, respectively, the smallest and largest values of the smallest bit- field that can store emin and emax. (On a two's-complement machine, bmax is the smallest value greater than or equal to max(abs(emin)-1,abs(emax)) of the form 2^M-1; bmin is zero if emin is non-negative and -(bmax+1) otherwise.) The implementation is not required to check for out of range values (of course) and you cannot derive subsets in the way of Ada subtypes.