C++ partial template specialization in combination with std::is_base_of and std::enable_if
问题 Let's say I have a two classes: Serializable and Printable . So a simple template function which accepts all derived classes of Printable could look like: template <class T, class B = Printable, class = typename std::enable_if<std::is_base_of<B, T>::value>::type> void print(T value) { cout << value << endl; } However, if I want it to accept also all derived classes of Serializable while I still have control over the function body, this would obviously not work: template <class T, class B =