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 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: g2news1.google.com!news3.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: What's wrong with C++? Date: Thu, 17 Feb 2011 19:53:17 +0100 Organization: A noiseless patient Spider Message-ID: <87zkpuze5e.fsf@ludovic-brenta.org> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="XVLOQe0bk3AY7hjNxi1+9g"; logging-data="8279"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Dll/E09eGFWkjFrinBIlT" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:bWg4fVlkS2ru5NRuv5MzTnzi+mI= sha1:9V4qqsxr3Bp0eaBZnrUInUF9h00= Xref: g2news1.google.com comp.lang.ada:17351 Date: 2011-02-17T19:53:17+01:00 List-Id: Yannick DuchĂȘne writes on comp.lang.ada: > 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 ? No, it only means that enumerations in C++ really are integers and not enumerations. Otherwise, how could the value Acid | Poison be in the set { Fire, Acid, Lightning, Poison } ? Hyman explained that enum values can be "promoted" automatically to int, but now he's just shown that ints such as the result of the bitwise OR of two enum values can also be "promoted" automatically to an enum type. Blech. -- Ludovic Brenta.