I want to do something like this...
class A;
class B;
class C;
void a(A);
void b(B);
void c(C);
template<typename T> void f(T t)
{
if (some condition)
a(t)
else if (some other condition)
b(t)
else
c(t);
}
int main()
{
A myA;
B myB;
C myC;
f(myA); // some condition ensures f(myA) only calls a(myA)
f(myB); // some condition ensures f(myB) only calls b(myB)
f(myC); // some condition ensures f(myC) only calls c(myC)
return 0;
}
But this doesn't compile because a(B), a(C), b(A), b(C), c(A), c(B) are not defined.
Is there a way to resolve this? I tried to see if std::function() or std::bind() could be used to construct a call to a(), b(), or c() dynamically, but no luck.