T
Tim Clacy
Your expertise will be appreciated...
Here's a general templatised class; all specialisations of this class should
have a pointer to a specialisation of the same, templatised type:
template<typename T, const int N>
struct Base : T
{
typedef Base<T, N> Type;
Type* pNext;
};
However, what if I want a specialisation that has the base class Type and
pNext members, but also a specific function:
// Specialisation of Base, with an additional interface
//
template<>
struct Base<SomeClass, 3>
{
void fn(void);
};
....this doesn't have the general base class members Type and pNext.
What's the correct thing to do here? If I specialise by derivation instead
of template specialisation, then in addition to the template(s) we'll need
derived types and to know what the derived type are called; I would really
like to be able to just use the template with specialisations for 'special'
flavours.
As usual, I ready to hang my head in shame when someone points out a better
approach
Tim
Here's a general templatised class; all specialisations of this class should
have a pointer to a specialisation of the same, templatised type:
template<typename T, const int N>
struct Base : T
{
typedef Base<T, N> Type;
Type* pNext;
};
However, what if I want a specialisation that has the base class Type and
pNext members, but also a specific function:
// Specialisation of Base, with an additional interface
//
template<>
struct Base<SomeClass, 3>
{
void fn(void);
};
....this doesn't have the general base class members Type and pNext.
What's the correct thing to do here? If I specialise by derivation instead
of template specialisation, then in addition to the template(s) we'll need
derived types and to know what the derived type are called; I would really
like to be able to just use the template with specialisations for 'special'
flavours.
As usual, I ready to hang my head in shame when someone points out a better
approach
Tim