I have a class template:
template<typename T>
struct DefaultPattern {
using type = int;
static int CalculateValue(const T& input) {
return 0;
}
};
For each type T
, I will have a specialization. The problem is that in the specialization class, I need to define all the member variables and methods that are defined in the DefaultPattern
, even though it is possible that they have the same value as the one in DefaultPattern
. Here is an example:
// A specialization for int.
template<>
struct DefaultPattern<int> {
// Same as DefaultPattern but I need to define it again.
using type = int;
static int CalculateValue(const int& input) {
return input + 2;
}
};
Is there a way so that when I do the specialization, I only need to define
those members that are different from DefaultPattern
?