Simply put, I'd like a compile-time check to ensure that a specific overload of a function exists. Either way the compilation will fail but I want a more useful error message to explain what needs to be fixed, as well as trying to reduce compiler spam as it tries to convert T into every known overload of other_serialize_func.
class Foo { /*....*/ };
std::string other_serialize_func(const Foo&) {}; // this function may or may not actually exist
template <typename T>
class Bar {
std::string serialize() {
static_assert(/*WHAT TO PUT HERE*/, "Type must have other_serialize_func(const T&) overload");
return other_serialize_func(T);
}
};