Thread View: comp.std.c++
1 messages
1 total messages
Started by Johan Wikman
Fri, 23 Feb 1996 15:55
Re: Problem with template overloading.
Author: Johan Wikman
Date: Fri, 23 Feb 1996 15:55
Date: Fri, 23 Feb 1996 15:55
41 lines
2104 bytes
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
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads