This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Template help,To Alexandre Oliva
- To: "Shiv Shankar Ramakrishnan" <Shiv at pspl dot co dot in>
- Subject: Re: Template help,To Alexandre Oliva
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 14 Nov 2000 02:36:56 -0200
- Cc: <gcc at gcc dot gnu dot org>, <louispp at hotmail dot com>
- Organization: GCC Team, Red Hat
- References: <NCBBJHKIIKAEAAGGMECNOEKJDFAA.Shiv@pspl.co.in>
On Nov 14, 2000, "Shiv Shankar Ramakrishnan" <Shiv@pspl.co.in> wrote:
> #if _MSC_VER >= 1200 //check for the version of your compiler
> #define TYPENAME_ typedef
> #else
> #define TYPENAME_ typename
> #endif
This is wrong. `typename' is not a replacement for `typedef'. In
this case, one must use typedef, because a type alias is what the
declaration is going to define, and typename, because it must precede
any template-dependent nested-name-specifiers that are supposed to be
typenames regardless of the template arguments used in an
instantiation.
So, you should define TYPENAME_ to either `typename' or `', and use:
typedef TYPENAME_ T1::Type1 Type1;
Note that there are other uses of the typename keyword, such as in
template parameters, that should either remain unchanged or be
substituted with the `class' keyword.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me