Topic: Member template specialization question
Author: Wayne Witzke <wwitzke@immersa.uky.edu>
Date: 2000/05/31 Raw View
I understand that the following will not work (it is specifically prohibited in
the standard):
template < typename T >
struct A
{
//...
template < typename T1 >
void myfunction(T1); // basic member template
//...
};
// Unspecialized implementation.
template < typename T >
template < typename T1 >
void A<T>::myfunction(T1 param)
{
// ...
}
template < typename T >
template<>
void A<T>::myfunction(int param)
{
// ...
}
The specialization is ill-formed due to the attempt to specialize the member
function without specializing the enclosing template class as well.
What I am wondering is why? Why is this specifically prohibited? I ran into a
problem not so long ago when this sort of specialization would have perfectly
suited the problem I was faced with. I ended up having to change the base class
to accomidate the specialization, which I really did not want to have to do as
there were seven template parameters in the base class, none of which were
actually used to define parameters or the return type of the member function I
was trying to specialize.
Can anybody provide any insight on this? Am I missing some important design
constraint? Thanks in advance.
Wayne
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]