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: 103376,9ce095aba33fe8d0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.uni-stuttgart.de!carbon.eu.sun.com!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: Martin Dowie Newsgroups: comp.lang.ada Subject: Re: Negative float problem Date: Tue, 1 Nov 2005 17:19:05 +0000 (UTC) Organization: BT Openworld Message-ID: References: <1130351574.313991.229420@g14g2000cwa.googlegroups.com> <10mspnley7gzu$.1swtj67sv0ldr$.dlg@40tude.net> <43677dec$1_1@glkas0286.greenlnk.net> <1130861070.985832.289890@g43g2000cwa.googlegroups.com> NNTP-Posting-Host: host86-131-222-60.range86-131.btcentralplus.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com 1130865545 25549 86.131.222.60 (1 Nov 2005 17:19:05 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Tue, 1 Nov 2005 17:19:05 +0000 (UTC) In-Reply-To: <1130861070.985832.289890@g43g2000cwa.googlegroups.com> X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) Xref: g2news1.google.com comp.lang.ada:6091 Date: 2005-11-01T17:19:05+00:00 List-Id: Hyman Rosen wrote: > Martin Dowie wrote: > >>Yup, you can't have overloaded enumeration values >>I guess because they are really just 'int', so which >>one would you mean? > > > No, that's not why. Enumerators have the type of their > enumeration. But enumerators go into their enclosing > namespace or class, so having multiple ones causes name > conflicts. You can actually simulate Ada's approach in > C++ by hand, as I show below. You can probably reduce > the boilerplate even more by using the Boost preprocessor > library, and that would also let you automatically get > string versions of the enumerators like Ada has. > > #include > #include > > struct Color { enum E { Red, Blue }; typedef E (&e)(E); }; > struct Traffic_Light { enum E { Green, Amber, Red }; typedef E (&e)(E); > }; > > #define EDEF(C,e) C::E e(C::E = C::e) { return C::e; } > EDEF(Color, Red) > EDEF(Color, Blue) > EDEF(Traffic_Light, Green) > EDEF(Traffic_Light, Amber) > EDEF(Traffic_Light, Red) > > void f_c(Color::e v) > { std::cout << "Color: " << v(Color::E()) << "\n"; } > void f_t(Traffic_Light::e v) > { std::cout << "Traffic_Light: " << v(Traffic_Light::E()) << "\n"; } > > // Notice there are two Reds defined at global scope with no conflict > // and that each function is called with the proper Red. > int main() { f_c(Red); f_t(Red); } > Thanks for that... ...although I might add this example to the list of reasons I really can't be bothered with C++ : what a palaver!!! ;-)