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: 103376,7f2ce8bda9cae4ab X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!informatik.uni-bremen.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: "Must instantiate controlled types at library level." Why? Date: Mon, 17 May 2004 16:31:10 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <1676457.GMYvKY1ieA@linux1.krischik.com> <1616198.O4tUV8TdF7@linux1.krischik.com> <87lljuvd6j.fsf@insalien.org> <874qqgpjok.fsf@insalien.org> <3tVpc.34871$vz5.29965@nwrdny01.gnilink.net> <2004517-94829-360098@foorum.com> <1084806067.140519@master.nyc.kbcfp.com> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1084811470 29707 134.91.1.34 (17 May 2004 16:31:10 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Mon, 17 May 2004 16:31:10 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: controlnews3.google.com comp.lang.ada:642 Date: 2004-05-17T16:31:10+00:00 List-Id: Hyman Rosen wrote: : template struct array { : T a[N]; : T &operator[](unsigned i) { return i < N ? a[i] : throw i; } : }; : : Now I can declare my array, for example, as array, : and pass it around by value. I haven't used #include. Right. And now, to the Ada fans, from a practical point of view, how does this compare to Ada arrays? At the C++ source level: you don't see any difference at the point of use because operator[] looks like always. In the compiler: I'm not sure, maybe some C++ compilers have switches for std [] vs .at? But, as Dmitry says, a useful template has been built by hand from the small things. (Lisp even gives you the lools for new syntax (re)definitions...) Is an approach based on discipline and conventinalism on a par with language definitions? Somewhat related to this, you can have template parameter constraints like Can_This or Can_That, as explained in http://www.research.att.com/~bs/bs_faq2.html#constraints But is it the same as saying generic type G is new C with private; ...