This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Template Explicit Instantiation error
- From: Ian Lance Taylor <iant at google dot com>
- To: GodfatherofSoul <godfatherofsoul2004 at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 02 Nov 2009 10:37:36 -0800
- Subject: Re: Template Explicit Instantiation error
- References: <26157764.post@talk.nabble.com>
GodfatherofSoul <godfatherofsoul2004@yahoo.com> writes:
> I'm trying to migrate some Visual Studio code to gcc, but I'm getting errors
> with some of our template usage:
>
> class ParentClass
> {
> public:
> class NestedForwardDeclaration;
>
> template class SomeTemplateClass<NestedForwardDeclaration>;
>
> class NestedForwardDeclaration
> {
> ...
> };
>
> };
>
> BTW, this is distilled down to the core cause of the problem, so you really
> can't see the rationale for this convention. The complication error I get
> is on the "template class.." line:
>
> error: expected `<' before 'class'
>
> Does anyone understand why this fails? Note that this same code compiles
> and runs with the Microsoft compiler.
The above test case (without the "...") fails because
SomeTemplateClass is not a template.
I'm not sure what you are trying to do in this code. If you are
trying to do an explicit instantiation of a template, then you have to
do the instantiation outside of ParentClass. You can't instantiate a
template inside a class; I'm not even sure what that would mean.
Ian