好ましいのはこれです:
template<typename T>
bool isNotZero(const T &a)
{
if (std::is_floating_point<T>::value) return abs(a) > std::numeric_limits<T>::epsilon();
else return a;
}
またはこれ:?
template<typename T>
std::enable_if<std::is_floating_point<T>::value, bool>::type
isNotZero(const T &a) { return abs(a) > std::numeric_limits<T>::epsilon(); }
template<typename T>
std::enable_if<std::is_integral<T>::value, bool>::type
isNotZero(const T &a) { return a; }
関数の多くのバージョンを避けるために、通常は最初のタイプを使用します。
まったく同じだと思います。
オペコード段階で最適化された最初のバージョンと、テンプレートのインスタンス化段階での 2 番目のバージョン。