This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Template specialization bug(s)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: Template specialization bug(s)
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Wed, 06 Sep 2000 11:29:37 -0600
- CC: Jon Lennard <jlennard at dsg dot com>
- Organization: Rogue Wave Software, Inc.
- References: <B756CDA1405ED411A2810008C75689D6B0C1@CRONUS.dsg.com>
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