I have a type Type and a variable tmp :
template<typename Type> myFunction()
{
/* SOMETHING */ tmp = 0;
};
I would like to declare tmp as Type if Type is a floating-point type and as double if Type is an integral type. How to do that in C++11 ?
I’m assuming
Tcan be only arithmetic type. If you want, you can usestd::is_arithmeticto check that first. See other helpful type traits here: