I have the following code:
// Case #1
float f = 1.0f;
float f2 = sqrt(f * pi);
// Case #2
double d = 1.0;
double d2 = sqrt(d * pi);
Is there any way to define the variable pi
so that operator*
and sqrt
will operate on float
s in Case #1, but will operate on double
s in Case #2?
Perhaps it might be possible with C++14 variable templates?