This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: explicit instantiation: function vs. class
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc at gcc dot gnu dot org>,"Vladimir Prus" <ghost at cs dot msu dot su>
- Date: Wed, 17 Mar 2004 17:04:56 +0100
- Subject: Re: explicit instantiation: function vs. class
- References: <c39qfg$ojs$1@sea.gmane.org>
Vladimir Prus wrote:
> namespace serialization {
>
> template<class T>
> class helper {};
>
> template<class T, class Seq>
> void
> boost_template_instantiate(T &,Seq &) {}
> }
>
> namespace X
> {
> class C {};
>
> template
> void
> serialization::boost_template_instantiate<>(X::C &, int &);
>
> template
> class serialization::helper<int>;
> }
> export4.cpp:26: error: declaration of `void
> boost_template_instantiate(X::C&,
> int&)' not in a namespace surrounding `serialization'
>
> The questions are:
>
> 1. Why the error? I could not find anything in the standard. It say
> that explicit specialization should be declared in the same
> namespace, but I see no restriction for instantiation.
I think the error is bogus. I cannot find evidence in the standard that the
explicit instantiation should be rejected because it happens in a different
scope.
> 2. Why the error happens for function only? The class is instantiated
> just fine.
This is a bug in GCC. Please, file a bug report in Bugzilla.
Giovanni Bajo