My template specialization does not work. Does anyone know how I can implement this function properly with templates?
template<class T>
float hz_to_nsec(const T &freq) {
return freq != 0 ? static_cast<float>(NSEC_PER_SEC) / freq : 0;
}
template <>
double hz_to_nsec<double>(const double &freq) {
return freq != 0 ? static_cast<double>(NSEC_PER_SEC) / freq : 0;
}
Aucun commentaire:
Enregistrer un commentaire