This is the mail archive of the gcc-bugs@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]

Re: Template specialization bug(s)


Jon Lennard wrote:
> 
> I encountered the following when specializing a template running
> version 2.95.2 on Solaris using "g++ template.cpp -o template".
> 
> The source is extremely short, so I included it below.
> The problems arise when defining the specialization outside of the
> declaration, i.e.
> 
>   template<>
    ^^^^^^^^^^

This is not allowed.

14.7.3, p5: ...Definitions of members of an explicitly specialized class
are defined in the same manner as members of normal classes, and not
using the explicit specialization syntax."


>   TemplateTest<char *>::TemplateTest(char *attr)
>     : attr_(attr)
>   {
>     std::cout << "in specialization" << std::endl;
>   }
> 
> This causes:
> template.cpp:30: template-id `TemplateTest<>' for
> `test::TemplateTest<char *>::TemplateTest(char *)' does not match any
> template declaration
> template.cpp:30: syntax error before `:'

I think a better error message would prevent any confusion on part of
the users.

Regards
Martin

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