I have a template math function that takes two values, does some math for them, and returns a value of the same type.
template <typename T> T math_function(T a, T b) { LongT x = MATH_OP1(a,b); return MATH_OP2(x,a); }
I want to store intermediate values ββ(in x) in a type that is basically a long version of T (above, called LongT). So, if T is a float, I want x to be double; and if T is int, I want x to be a long int.
Is there any way to do this? I tried enable_if , but it seems to me that I really need enable_if_else .
I would prefer the compiler to understand what to use for LongT on its own. I would prefer not to specify it when calling the function.
source share