🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3422

Re: Problem with template overloading.

#3422
From: Johan Wikman
Date: Fri, 23 Feb 1996 15:55
41 lines
2104 bytes
In article <4gi7h0$l0@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM (Steve Clamage) writes:

>  In article AA11584@garlic.spices, wikman@research.nokia.com (Johan Wikman)
>  writes:
>
>  >I'd like to be able to have a class and a template with the same name
>  >in the same scope. 
>
>	   class A { ... };
>
>	   template <class T>
>	   class A {
>		   void foo() { .... A ... }
>	   };
>
>   In A<T>::foo, I use the identifier "A". Does that refer to the template
>   or to the class? In order not to break all existing code, it must
>   refer to the template. 

Interesting, I always thought you had to use A<T>. Now that I tried
it, all compilers I have access to (HP, gcc and MS VC++) accepted both
A and A<T>. What does the standard say? Are both versions allowed?
 
>   Perhaps you can think of a special syntax that won't change the meaning
>   of existing code, or we could say that you can't refer to class A anywhere
>   in the scope of template A. 

No, I won't even try. But I definitely find using A<T> within the
definition of a template's function more intuitive than just using
A. Making A<T> a requirement certainly wouldn't break my code;-). 

--
johan.wikman@research.nokia.com


[ To submit articles: Try just posting with your newsreader.
		      If that fails, use mailto:std-c++@ncar.ucar.edu
  FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID: <9602231434.AA15034@garlic.spices>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: wikman@research.nokia.com (Johan Wikman)
Newsgroups: comp.std.c++
Subject: Re: Problem with template overloading.
Date: 23 Feb 1996 15:55:23 GMT
Organization: ?
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <9602231434.AA15034@garlic.spices>
NNTP-Posting-Host: taumet.eng.sun.com
Mime-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Mailer: ELM [version 2.4 PL24alpha5]
X-Lines: 34
Content-Length: 1194
Originator: clamage@taumet