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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fce663eaf40b52f6 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed.mathworks.com!irazu.switch.ch!switch.ch!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Ranges in C++ Date: Mon, 10 May 2004 20:04:09 +0200 Organization: AdaCL Message-ID: <1802641.IB4YAx8xDq@linux1.krischik.com> References: <1327280.rH5RGlINvC@linux1.krischik.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1084212914 01 5000 htnNGs7leOLJSmKl 040510 18:15:14 X-Complaints-To: usenet-abuse@t-online.de X-ID: SS23V2Zpgeck1MnDa4s+iopVTo8SA5GoshX3PKt9-vN3KRpfJWLesO User-Agent: KNode/0.7.7 Xref: controlnews3.google.com comp.lang.ada:424 Date: 2004-05-10T20:04:09+02:00 List-Id: Xenos wrote: > "James Rogers" wrote in message > news:Xns94E2AF95950Ajimmaureenrogers@204.127.36.1... >> Martin Krischik wrote in >> news:1327280.rH5RGlINvC@linux1.krischik.com: >> > Xenos wrote: >> >> As a programmer of both Ada and C++, I too am glad. When I have to >> >> use Ada, >> >> I sorely miss the STL. Of course, when I have to use C++, I miss >> >> unique (new) types derived from primative types...and ranges (oh how >> >> I miss ranges!), oh and arrays as first-class types. >> > I have implemented a little C++ Template-Library emulating ranges. >> > It's not at cool as ranges but it works. If you want I package it up >> > and make a release for you. > Yeah, I have done something similar. I had it so it would use the class > type to check ranges in development builds, and use actual primative types > in release builds. I did an implementation on templates. i.E. typedef IntegerRange<1, 31> DayOfMonth; typedef IntegerRange<1, 12> MonthOfYear; Apart from Image and Value all functions are inlined and only the value but not First and Last need to stored. This is closer to the Ada original and should give better performace. Also a template implentation gives you real types while a class implementation gives only subtypes. Think of: Set (DayOfMonth Day); Set (MonthOfYear Month); And yes: no "const&" the type can be used like an integer. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com