This is the mail archive of the gcc@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: explicit instantiation: function vs. class


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



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