Type lookup problem in local template class?
Richard Guenther
rguenth@tat.physik.uni-tuebingen.de
Thu Nov 21 07:44:00 GMT 2002
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/
More information about the Gcc
mailing list