I have a class template. Each of the instantiations implements a method
in the class template differently, so I (need?) to use template
speciaization.
My question is this, when writing the specialization, do I need to
implement only the method that is 'different', or do I need to implement
all the methods in the class template?
template <typename T1, typename T2>
class MyClass
{
void foo(const T1&, T2&) const;
...
//other methods follow below
int foobar(T1, T1, T2&);
// ...etc
};
template<>
class MyClass<int,dou ble>
{
void foo(const int& i, double& d) const
{
//'specialized' logic here
}
/* Do I need all the other methods here ?
.... */
};
in the class template differently, so I (need?) to use template
speciaization.
My question is this, when writing the specialization, do I need to
implement only the method that is 'different', or do I need to implement
all the methods in the class template?
template <typename T1, typename T2>
class MyClass
{
void foo(const T1&, T2&) const;
...
//other methods follow below
int foobar(T1, T1, T2&);
// ...etc
};
template<>
class MyClass<int,dou ble>
{
void foo(const int& i, double& d) const
{
//'specialized' logic here
}
/* Do I need all the other methods here ?
.... */
};
Comment