Specialize function if argument has member variable
问题 I have a function for error reporting that is templated because it can report errors for many different message classes: template <typename MSG> void reportErr(const MSG& msg) { std::cout << "ERROR: " << msg.error << std::endl; } However, some types of message have more detailed error that can be reported or other specialized error reporting, e.g. template<> void reportErr(const SpecificMsg& msg) { std::cout << "ERROR: " << msg.error; std::cout << ", details: " << msg.details << std::endl; }