Detecting whether a class has a specific member function at compile-time:
template<typename T, typename = void>
struct has_serialize : std::false_type {};
template<typename T>
struct has_serialize<T, std::void_t<decltype(std::declval<T>().Serialize())>> : std::true_type {};
// Usage
static_assert(has_serialize<MyPacket>::value, "MyPacket must implement Serialize()");std::void_t maps any valid type expression to void. If T.Serialize() is invalid, SFINAE drops the specialization cleanly without compiler errors!