I have a class which has two template parameters, the doLeft/doRight member function only relies on one template parameter (i.e. Left/Right), and doBoth relies on both parameters. It seems that C++ does not support partial specialization of a member.
What is the best way to approximate it?
template<typename Left, typename Right>
class RightandLeft {
void do() {
doLeft();
doRight();
doBoth();
}
void doLeft();
void doRight();
void doBoth();
}
// when left type is int64, do something based on int64,
// right type can be any type. How should I achieve it?
template<typename right>
void RightandLeft<int64_t, right>::doLeft() {
}
// when right type is string, do something based on string,
// left type can be any type. How should I achieve it?
template<typename left>
void RightandLeft<left, string>::doRight() {
}
template<typename left, typename right>
void RightandLeft<left, right>::doBoth(){};