I have this code
class Foo {
private:
enum class Heuristic {
ONE,
TWO,
THREE
};
Heuristic h;
void select();
};
void Foo::select() {
if (h == Heuristic::ONE)
selectONE();
else if (h == Heuristic::TWO)
selectTWO();
else
selectTHREE();
}
void selectONE() {};
void selectTWO() {};
void selectTHREE() {};
Based on the value of heuristic
I want to call a specific function in select()
. I don't know the value of heuristic
at compile time, as it depends on user input. To avoid the conditional check in select()
I would like to use templates. How can I accomplish this?