this question is related to c++
there is a library which declares a class named Solver < TS,FS >. Solver is a member of another class Domain (written by me)
now there are many Domains which have a member “int region”
what i want to do is depending on the value of region, I want to make the solver accept different arguments for TS and FS.
I was thinking of something along the line
template<int region>
struct Decider
{
if(region==1)
{
typedef TSA TS;
typedef FSA FS;
}
else
if(region==2)
{
typedef TSB TS;
typedef FSB FS;
}
}
and later use it as
Decider<region>::TS
Decider<region>::FS
However, here due to the scope of the if, i guess the struct is useless. However, I am not able to think of a better method to do this. Any suggestions?
All the different TS and FS have the same interface. So I don’t have to worry about the inside code.
You can specialize a template for any
regionvalue.