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,897417b380f5731e X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: STL, Ada, C++ (Was Re: The Next Microsoft?) Date: 2000/05/09 Message-ID: #1/1 X-Deja-AN: 621326234 Sender: hymie@calumny.jyacc.com References: <8eu0ob$7qv$1@nnrp1.deja.com> <391328F0.1221@synquiry.com> <39133213.64A@Ganymede.com> <8f50hc$hpo$1@nnrp1.deja.com> <8f83i2$osk$1@slb1.atl.mindspring.net> X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 957912776 28425 209.49.126.226 (9 May 2000 22:52:56 GMT) Organization: PANIX Public Access Internet and UNIX, NYC NNTP-Posting-Date: 9 May 2000 22:52:56 GMT Newsgroups: comp.lang.ada Date: 2000-05-09T22:52:56+00:00 List-Id: Robert A Duff writes: > Hyman Rosen writes: > > The C++ Standard requires support for a minimum of 17 levels of templates. > > The GNU compiler has a command-line argument to specify what depth you want > > if you need more. > > Why? I mean, why is there a need for a limit? (And, less importantly, > why 17?) The depth of template nesting is potentially unlimited, and erroneous code can require infinite depth, so the standard sets a minimum depth that must be supported, and strictly conforming code shouldn't require anything deeper. Here's a trivial example - template struct factorial { enum { v = N * factorial::v }; }; template <> struct factorial<0> { enum { v = 1 }; }; If I use factorial<5>::v, I'm fine. If I use factorial<20>::v, I've gone over 17 levels, and a strictly conforming compiler doesn't have to accept my code. If I use factorial<-1>::v, I'm very happy that my compiler has some limit :-)