Should I declare my function template specializations or is defining them enough?
问题 I have some classes which can be checked. The code which implements this declares a function template in a header file and specializes it in different source files: // check.h template <class T> bool check(const T& object); // class1.h struct Class1 {int mass;}; // check_class1.cpp #include "class1.h" #include "check.h" template <> bool check(const Class1& object) {return object.mass < 100;} // class2.h struct Class2 {int price;}; // check_class2.cpp #include "class2.h" #include "check.h"