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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9cccf6ef6149fdaa X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Ada Date: 2000/01/04 Message-ID: #1/1 X-Deja-AN: 568252787 Sender: hymie@calumny.jyacc.com References: <38620350.48F8FC08@gecm.com> <83tohh$q2s$1@nnrp1.deja.com> <83u8l0$5i5$1@nnrp1.deja.com> <84rd2f$snm$1@nntp3.atl.mindspring.net> <84t8b1$ar5$1@nnrp1.deja.com> X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 947010981 7926 209.49.126.226 (4 Jan 2000 18:36:21 GMT) Organization: PANIX Public Access Internet and UNIX, NYC NNTP-Posting-Date: 4 Jan 2000 18:36:21 GMT Newsgroups: comp.lang.ada Date: 2000-01-04T18:36:21+00:00 List-Id: Robert A Duff writes: > Even worse, it means that literals can't be overloaded. Of course, C++ > doesn't even *have* enumeration literals of different enumeration types, > anyway. It certainly does. The problematic part is that enumeration literals are entered into the scope in which the enumeration type is declared, because of backward compatibility with C. As a result, one normally declares enumerated types inside a class or namespace, so that literals won't conflict. If you really need enumerator literal overloading, you can play the same game as for empty sets, on a case-by-case basis: struct Direction { enum E { Left, Right, Up, Down }; }; struct Politics { enum E { Left, Center, Right }; }; static struct { operator Direction::E() { return Direction::Left; } operator Politics ::E() { return Politics ::Left; } } Left; static struct { operator Direction::E() { return Direction::Right; } operator Politics ::E() { return Politics ::Right; } } Right; void f(Direction::E) { } void g(Politics ::E) { } int main() { f(Left); f(Right); g(Left); g(Right); }