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]

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





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