This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Template Explicit Instantiation error


Hi,
On Mon, Nov 02, 2009 at 10:20:12AM -0800, GodfatherofSoul wrote:
> 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?  

Yes, I believe so;-)

> Note that this same code compiles and runs with the Microsoft compiler.

It shouldn't... According to the C++-standard, you have to write instead

template <> class SomeTemplateClass<NestedForwardDeclaration>;

Axel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]