I want do this:
func(conditionA ? pa1 : pa2, conditionB ? pb1 : pb2, conditionC ? pc1 : pc2);
In C style function, there is no problem. But if func() is a template function, compiler will report errors. Here pa1 and pa2, ... are different class and have a static method - "convert()". convert() is also declared as inline for performance consideration.
If template cannot solve this problem, there will be a very looooooooooong if-else like below.
if (conditionA)
{
typeA1 a;
if (conditionB)
{
typeB1 b;
if (conditonC)
{
C1 c;
Function(a, b, c);
}
else
{
C2 c;
Function(a, b, c);
}
}
else
{
typeB2 b;
if (conditonC)
{
C1 c;
Function(a, b, c);
}
else
{
C2 c;
Function(a, b, c);
}
}
}
else
{
typeA2 a;
if (conditionB)
{
typeB1 b;
if (conditonC)
{
C1 c;
Function(a, b, c);
}
else
{
C2 c;
Function(a, b, c);
}
}
else
{
typeB2 b;
if (conditonC)
{
C1 c;
Function(a, b, c);
}
else
{
C2 c;
Function(a, b, c);
}
}
}