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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-ArrivalTime: 2001-08-14 06:25:54 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!dispose.news.demon.net!demon!grolier!nerim.net!norfair.nerim.net!not-for-mail From: "Bertrand Augereau" Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Subject: Re: How Ada could have prevented the Red Code distributed denial of service attack. Date: Tue, 14 Aug 2001 15:32:04 +0200 Organization: Nerim -- xDSL Internet Provider Message-ID: <9lb8t1$7r7$1@norfair.nerim.net> References: <3b690498.1111845720@news.worldonline.nl> <9kbu15$9bj@augusta.math.psu.edu> <9kbvsr$a02@augusta.math.psu.edu> <3B69DB35.4412459E@home.com> <3B6F312F.DA4E178E@home.com> <23lok9.ioi.ln@10.0.0.2> <3B70AB15.35845A98@home.com> <3B721FF5.B7D854F6@home.com> <9lb6h4$6e9$1@norfair.nerim.net> NNTP-Posting-Host: aboukir-101-2-1-inutero.adsl.nerim.net X-Trace: norfair.nerim.net 997795553 8039 62.4.19.69 (14 Aug 2001 13:25:53 GMT) X-Complaints-To: abuse@nerim.net NNTP-Posting-Date: Tue, 14 Aug 2001 13:25:53 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:11911 comp.lang.c:74150 comp.lang.c++:82454 Date: 2001-08-14T15:32:04+02:00 List-Id: > With templates, you can evaluate this mapping at compile time, > enum A {a=12,b=38,c=95}; > > template const char* GetImage (void); > template<> const char* GetImage (void) { return "a"; } > template<> const char* GetImage (void) { return "b"; } > template<> const char* GetImage (void) { return "c"; } > Ok, sorry for the previous answer, I didn't get the fact that 'Image was giving the string at run-time depending of the actual value of the enum. In fact's there's no other way for implementing this pattern that a big switch, which is way less elegant than 'Image attribute, which leaves the task to the compiler.