Topic: template<class T> X { typedef T T ; } ; illegal?
Author: "Victor Bazarov" <vAbazarov@dAnai.com>
Date: 28 Aug 2002 17:50:18 GMT Raw View
"Fernando Cacciola" <fcacciola@gosierra.com> wrote...
> I notice today that Comeau Online says that
>
> "template parameter "T" may not be redeclared in this scope"
>
> when compiling this:
>
> template<class T>
> struct X
> {
> typedef T T ;
> } ;
>
> It's true that 14.6.1/4 says that a template parameter shall not be
> redeclared within its scope, but I think that it refers to the case when
the
> redeclaration differs.
>
It is probably done for simplicity and consistency. What is your
intention when you write
typedef T T;
? Well, first of all, it behaves the same way as
typedef int int;
which would be a redefinition of 'int', and as such, an error.
Second, if you write such statement, you've most likely made
a typo because there is no reason to have a statement that does
nothing, is there? IMO, the language is define so that we avoid
such mistakes.
Victor
--
Please remove capital A's from my address when replying by mail
---
[ 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: "Fernando Cacciola" <fcacciola@gosierra.com>
Date: Sat, 15 Jun 2002 06:21:40 GMT Raw View
Hi!
I notice today that Comeau Online says that
"template parameter "T" may not be redeclared in this scope"
when compiling this:
template<class T>
struct X
{
typedef T T ;
} ;
It's true that 14.6.1/4 says that a template parameter shall not be
redeclared within its scope, but I think that it refers to the case when the
redeclaration differs.
--
Fernando Cacciola
Sierra s.r.l.
fcacciola@gosierra.com
www.gosierra.com
---
[ 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 ]