I\'d like to perform similar, but not identical computations for several integer types (16, 32, 64 bits) and floating point types (float, double, long double). Most of the code
Yes, you can use SFINAE in combination with the metafunctions from
#include
template
typename std::enable_if<
std::is_integral::value,
bool>::type
isEqual(IntegralType a,IntegralType b)
{
return a == b;
}
template
typename std::enable_if<
std::is_floating_point::value,
bool>::type
isEqual(FloatingType a,FloatingType b)
{
return fabs(a-b) < std::numeric_limits::epsilon();
}