Thread View: comp.std.c++
2 messages
2 total messages
Started by brian (b.c.) white
Sun, 18 Feb 1996 02:14
Problem with template overloading
Author: brian (b.c.) white
Date: Sun, 18 Feb 1996 02:14
Date: Sun, 18 Feb 1996 02:14
39 lines
1728 bytes
1728 bytes
Is it allowed to overload template names based on their parameters
in the same way that functions can be overloaded?
I tried to create two versions of the same class name as such:
template <class C>
class A {
[...]
};
template <class C1, class C2>
class A {
[...]
};
Gcc 2.7.2 gives errors about redefinition even though, as far as I can
tell, these names are distinct.
test.cc:8: declaration of template `template <class C1, class C2> class A'
test.cc:2: conflicts with previous declaration `template <class C> class A'
In the end, I had to create two classes: A1 and A2.
Is this a problem with GCC or does the standard not allow it?
Brian
( bcwhite@bnr.ca )
-------------------------------------------------------------------------------
In theory, theory and practice are the same. In practice, they're not.
[ 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
]
Re: Problem with template overloading
Author: Steve Clamage
Date: Sun, 18 Feb 1996 06:05
Date: Sun, 18 Feb 1996 06:05
33 lines
1552 bytes
1552 bytes
"brian (b.c.) white" <bcwhite@bnr.ca> writes:
>Is it allowed to overload template names based on their parameters
>in the same way that functions can be overloaded?
>I tried to create two versions of the same class name as such:
>template <class C>
>class A {
> [...]
>};
>template <class C1, class C2>
>class A {
> [...]
>};
No, that is not allowed. You cannot have more than one template
with the same name in the same scope.
The closest you could come would be to use a default template
parameter or partial specialization. Not all compilers support
those features yet.
--
Steve Clamage, stephen.clamage@eng.sun.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