I want to write a function
template <class Arg>
tuple<int, double> calc(Arg arg);
It returns:
[arg,0] if arg is int,
[0,arg] if arg is double
and [0,0] if arg is nor int or double.
I implement this function comparing the type of arg (Arg), type of i (int) and type of d (double) and then equating i=arg or d=arg respectively. But if I want to use my function with a string or another type, which can not be converted to int/double, I have a conversion error (its clear, cause I can't equate char* to int, for example). How can I bypass this conversion const char* to int (or another inconvertible type to int)? Or maybe there is another implementation of this function?
#define GETTYPE(x) typeid(x).name()
template <class Arg>
tuple<int,double> calc(Arg arg)
{
int i = 0;
double d = 0;
if (GETTYPE(arg) == GETTYPE(i))
{
i = arg;
}
else if (GETTYPE(arg) == GETTYPE(d))
{
d = arg;
}
return make_tuple(i, d);
}