This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Template specialization error for "void" template parameter in GCC
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "himanshu.gupta" <himanshu12 dot g at tcs dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 21 Sep 2011 09:15:13 +0100
- Subject: Re: Template specialization error for "void" template parameter in GCC
- References: <32503711.post@talk.nabble.com>
On 21 September 2011 06:21, himanshu.gupta wrote:
>
> Hi,
>
> The following code is giving errors while compiling with GCC 4.5.
>
> Foo.h Header File: declaration of template class.
> template<class T>
> class Foo
> {
> ? ?void FooBar() const;
> };
>
> Foo.cpp Source File: explicit definitions for member function of template
> class Foo.
> template<>
> void Foo<void>::FooBar () const
> {
> ? ?do something...
> }
>
> The above explicit function declaration for "void" is giving error...
> error: template-id 'type<>' for 'void Foo<void>::FooBar() const' does not
> match any template declaration
>
> The same explicit function declarations with other types - int, unsigned
> int, etc. compiles successfully. The explicit specialization for "void"
> however seems to only compile without template<> being added. But I believe
> as per GCC they do require template<>.
>
> Is it an error with GCC for "void" template parameter? Or am I missing
> something with syntax/ GCC compile option?
It looks as though you've forgotten to #include "Foo.h"