M
Martin
I have a couple of partial specializations of a templated class, but
my code results in "undefined reference" errors by the linker.
Can't a partial specialization reuse member functions of the generic
template definition? If not, is there any way to avoid the great
amount of copy-paste code involved in copying the generic member
definitions into the partial specializations?
template<int D, class F>
struct L
{
void f();
void g();
};
template<int D, class F>
void L<D,F>::f()
{
// common code
}
template<class F>
struct L<3,F>
{
void f();
void g();
};
template<class F>
void L<3,F>::g()
{
// partial specialization
}
int main( )
{
L<3,int> l;
l.f();
return 0;
}
my code results in "undefined reference" errors by the linker.
Can't a partial specialization reuse member functions of the generic
template definition? If not, is there any way to avoid the great
amount of copy-paste code involved in copying the generic member
definitions into the partial specializations?
template<int D, class F>
struct L
{
void f();
void g();
};
template<int D, class F>
void L<D,F>::f()
{
// common code
}
template<class F>
struct L<3,F>
{
void f();
void g();
};
template<class F>
void L<3,F>::g()
{
// partial specialization
}
int main( )
{
L<3,int> l;
l.f();
return 0;
}