From 3872258431923591064
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,c45bddfadd5b4855
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-09-14 00:23:18 PST
Path: bga.com!news.sprintlink.net!sundog.tiac.net!usenet.elf.com!news2.near.net!MathWorks.Com!yeshua.marcam.com!charnel.ecst.csuchico.edu!olivea!koriel!male.EBay.Sun.COM!engnews1.Eng.Sun.COM!engnews2.Eng.Sun.COM!usenet
From: clamage@Eng.Sun.COM (Steve Clamage)
Newsgroups: comp.std.c++
Subject: Re: C++ templates standard
Date: 13 Sep 1994 21:49:38 GMT
Organization: Sun Microcomputer Corporation
Lines: 34
Message-ID: <3556pi$290@engnews2.Eng.Sun.COM>
References: <Cw06vx.1yu@hpgndlab.grenoble.hp.com>
Reply-To: clamage@Eng.Sun.COM
NNTP-Posting-Host: taumet.eng.sun.com

In article 1yu@hpgndlab.grenoble.hp.com, jr@grenoble.hp.com (Jean-Rene Bouvier) writes:
>In article <JASON.94Sep7141307@deneb.cygnus.com>, jason@cygnus.com (Jason Merrill) writes:
>> >>>>> Jean-Rene Bouvier <jr@grenoble.hp.com> writes:
>> 
>> > I've tried several compilers for the following piece of code, but none
>> > accepted it.
>> > Does anyone know whether my code is legal or not ?
>> 
>> It isn't.  Class templates cannot be nested.
>> 
>> Jason
>
>Is there any reason - besides compilers complexity - to forbid nested
>templates. I can't see why there would be an issue with them, has that
>question been debated at ANSI ?

This is explained in detail in "The Design and Evolution of C++".

When the template feature was being designed, no one knew what all the 
consequences would be of nested templates, and there were no actual
implementations of templates at the time the ARM was written. Rather than
allow something that might later have to be removed from the language,
Stroustrup made the rule that templates may appear only at file scope.

Later experience has showed that there are indeed some problems, particularly
with allowing template virtual functions, but that for most cases the rule
about file scope can be relaxed. The C++ Committee has approved a relaxed
rule. Few, if any, compilers allow nested templates yet because the feature
is too new.

---
Steve Clamage, stephen.clamage@eng.sun.com




