Topic: Nested templates explicit specialization
Author: shnyr@mailcity.com (Andriy Shnyr)
Date: Wed, 3 Dec 2003 17:35:21 +0000 (UTC) Raw View
Let us consider the following nested templates case:
template<typename T>
class Outer{
public:
template<typename U>
class Inner{
public:
void f();
};
};
Then the following specialization
template<> template<typename U> void Outer<int>::Inner<U>::f(){};
results in compile-time error (I've tried to compile it with gcc 3.2.2)
main.cpp:XXX: invalid use of undefined type `class Outer<int>::Inner<U>'
main.cpp:XXX: declaration of `class Outer<int>::Inner<U>'
main.cpp:XXX: template definition of non-template `void
Outer<int>::Inner<U>::f()'
Can anyone help me to figure out the problem?
Thanks in advnace,
Andriy Shnyr
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: cppljevans@cox-internet.com (Larry Evans)
Date: Thu, 4 Dec 2003 04:54:11 +0000 (UTC) Raw View
On 12/03/2003 11:35 AM, Andriy Shnyr wrote:
[snip]
> main.cpp:XXX: invalid use of undefined type `class Outer<int>::Inner<U>'
> main.cpp:XXX: declaration of `class Outer<int>::Inner<U>'
> main.cpp:XXX: template definition of non-template `void
> Outer<int>::Inner<U>::f()'
>
> Can anyone help me to figure out the problem?
IIRC, adding ::template Inner<U> solved the compile problem for me;
however, I found a problem with the produced code not selecting the
right specialization, as reported here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13088
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]