This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Type lookup problem in local template class?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: <gcc at gcc dot gnu dot org>
- Date: Thu, 21 Nov 2002 12:13:00 +0100 (CET)
- Subject: Re: Type lookup problem in local template class?
On Wed, 20 Nov 2002, Richard Guenther wrote:
> The following code gives a parse error with g++ 3.2 (3.0, too):
>
> template <class X>
> struct B {
> template <class Y>
> struct C {
> typedef Y Y_t;
> void foo(Y_t&);
> };
> };
>
> template <class X, class Y>
> void B<X>::template C<Y>::foo(Y_t&)
> {
> }
>
> If changing Y for Y_t in the definition of foo the parse error
> goes away. Intel icpc 6.0.1 does not parse this in any of both
> cases. Clearly Y_t should be visible in foo, no? If not, is the
> intel compiler right in rejecting the code if using Y instead of
> Y_t?
Just to note, Intel icpc is fine with
template <class X>
template <class Y>
void B<X>::template C<Y>::foo(Y&) {}
while g++ (3.0 and 3.2) give
localclass.cpp:14: too many template parameter lists in declaration of
`void
foo(Y&)'
localclass.cpp:14: syntax error before `{' token
And both compilers are happy again, if I specify
template <class X>
template <class Y>
void B<X>::C<Y>::foo(Y&) {}
Oh well, Richard.
--
Richard Guenther <richard.guenther@uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/