jeudi 22 août 2019

template method "=0" in the parameter list

I saw code like the following:

using EnableIfIntegral = typename std::enable_if<
    std::is_integral<T>::value || std::is_enum<T>::value, int>::type;

template <typename T, EnableIfIntegral<T> = 0>
constexpr int Seconds(T n) {
  return time_internal::FromInt64(n, std::ratio<1>{});
}

template <std::intmax_t N>
constexpr int FromInt64(int64_t v, std::ratio<1, N>) {
  // Do Something
}


I understand what a template function is. Why in the template parameter list, does it have SomeClass<T> = 0? I know T is the template parameter.

Why is std::ratio<1, N> a parameter?

Aucun commentaire:

Enregistrer un commentaire