From: Hyman Rosen <hymie@prolifics.com>
Subject: Re: STL, Ada, C++ (Was Re: The Next Microsoft?)
Date: 2000/05/09
Date: 2000-05-09T22:52:56+00:00 [thread overview]
Message-ID: <t7puqv2v5a.fsf@calumny.jyacc.com> (raw)
In-Reply-To: wccn1lzmjno.fsf@world.std.com
Robert A Duff <bobduff@world.std.com> writes:
> Hyman Rosen <hymie@prolifics.com> 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 <int N>
struct factorial
{
enum { v = N * factorial<N - 1>::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 :-)
next prev parent reply other threads:[~2000-05-09 0:00 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <8eg37k$15n$1@nnrp1.deja.com>
[not found] ` <8epkoa$b8b$1@nnrp1.deja.com>
[not found] ` <E$OcUgAHHIE5Ewfl@quik.freeuk.net>
[not found] ` <8eu0ob$7qv$1@nnrp1.deja.com>
2000-05-05 0:00 ` The Next Microsoft? Ray Blaak
2000-05-05 0:00 ` Mark Atwood
2000-05-05 0:00 ` Hyman Rosen
2000-05-05 0:00 ` Mark Atwood
2000-05-05 0:00 ` Hyman Rosen
2000-05-05 0:00 ` Jon S Anthony
2000-05-05 0:00 ` Hyman Rosen
2000-05-05 0:00 ` Jon S Anthony
2000-05-05 0:00 ` Bill Greene
2000-05-06 0:00 ` Ehud Lamm
2000-05-07 0:00 ` STL, Ada, C++ (Was Re: The Next Microsoft?) Brian Rogoff
2000-05-08 0:00 ` Florian Weimer
2000-05-08 0:00 ` Robert Dewar
2000-05-07 0:00 ` Brian Rogoff
2000-05-08 0:00 ` Hyman Rosen
2000-05-08 0:00 ` Brian Rogoff
2000-05-09 0:00 ` Richard D Riehle
2000-05-09 0:00 ` Brian Rogoff
2000-05-09 0:00 ` Brian Rogoff
2000-05-09 0:00 ` Hyman Rosen
2000-05-09 0:00 ` Robert A Duff
2000-05-09 0:00 ` Hyman Rosen [this message]
2000-05-10 0:00 ` Richard D Riehle
2000-05-10 0:00 ` Brian Rogoff
2000-05-08 0:00 ` Pascal Obry
2000-05-08 0:00 ` Brian Rogoff
2000-05-08 0:00 ` Robert Dewar
2000-05-08 0:00 ` Pascal Obry
2000-05-09 0:00 ` STL, Ada, C++ Harry Erwin
2000-05-09 0:00 ` Robert A Duff
2000-05-09 0:00 ` STL, Ada, C++ (Was Re: The Next Microsoft?) Marin D. Condic
2000-05-09 0:00 ` Robert Dewar
2000-05-09 0:00 ` Marin D. Condic
2000-05-05 0:00 ` The Next Microsoft? Ayende Rahien
2000-05-05 0:00 ` Bobby D. Bryant
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox