If I have a template class
template<typename T>
class C {
public:
void method1() { ... }
void method2() { ... }
std::string method3(T &t) {
// ...
std::string s = t.SerializeToString();
// ...
return s;
}
// ...
};
and I want to specialize it for T = std::string
but only changing method3(T&)
(keeping all other methods), or even better, only that part of method3, which for T = std::string
would simply become std::string s = t;
, with minimum impact on current code (less repetition of methods signatures, less subclassing), how would I do it?
EDIT: I'm developing in C++11