This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
explicit instantiation: function vs. class
- From: Vladimir Prus <ghost at cs dot msu dot su>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 17 Mar 2004 18:22:12 +0300
- Subject: explicit instantiation: function vs. class
Hello,
I have a problem where explicit instantiation of a class works, but for a
function does not. Consider the following example:
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>;
}
Using gcc version 3.3.3 20040125 (prerelease) (Debian) I get:
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.
2. Why the error happens for function only? The class is instantiated just
fine.
Thanks,
Volodya