R
Rob Williscroft
Paul Schneider wrote in in
comp.lang.c++:
Standard C++ doesn't allow function's (member or not) to be partialy
specialized, you may however add overloads and you may have explicit
specialization's.
If neither of the above is of use to you, implement you function in
a helper class, and partialy specialize the helper:
/* Untested code, expect typo's */
struct X;
template < typename T >
struct helper
{
static void apply( X *that )
{
// default body for X::f< T >() goes here
}
};
struct X
{
template < typename T > void f()
{
helper< T >::apply( this );
}
};
/* Now *partialy* specialize
*/
#include <complex>
template < typename T >
struct helper< std::complex< T > >
{
static void apply( X *that )
{
// body for X::f< std::complex< T > >() goes here
}
};
HTH.
Rob.
comp.lang.c++:
I am getting compiler errors with the following setup
Standard C++ doesn't allow function's (member or not) to be partialy
specialized, you may however add overloads and you may have explicit
specialization's.
If neither of the above is of use to you, implement you function in
a helper class, and partialy specialize the helper:
/* Untested code, expect typo's */
struct X;
template < typename T >
struct helper
{
static void apply( X *that )
{
// default body for X::f< T >() goes here
}
};
struct X
{
template < typename T > void f()
{
helper< T >::apply( this );
}
};
/* Now *partialy* specialize
*/
#include <complex>
template < typename T >
struct helper< std::complex< T > >
{
static void apply( X *that )
{
// body for X::f< std::complex< T > >() goes here
}
};
HTH.
Rob.