explicit instantiation: function vs. class
Giovanni Bajo
giovannibajo@libero.it
Wed Mar 17 16:40:00 GMT 2004
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
More information about the Gcc
mailing list