Function templates: extern template vs explicit specialisation
问题 Consider the following function template declaration: template <typename T, typename = std::enable_if_t<std::is_same_v<T, int>>> void foo(T i); There is only one possible valid instantiation of this template, namely with T = int . I'd like to put this definition in an implementation file. I can think of two possible ways of doing so. (If you're wondering why on earth I'd do this rather than just saying void foo(int i) , it's because the template version prevents implicit conversions at the