#include template class FunctorToStaticMethodAdaptor : public FunctorToStaticMethodAdaptor { public: }; template class FunctorToStaticMethodAdaptor { public: static R call(C * ptr, Args... arguments) { return std::invoke(&C::operator(), ptr, arguments...); } static R unsafeCall(char * ptr, Args... arguments) { C * ptr_typed = reinterpret_cast(ptr); return std::invoke(&C::operator(), ptr_typed, arguments...); } }; template class FunctorToStaticMethodAdaptor { public: static R call(C * ptr, Args... arguments) { return std::invoke(&C::operator(), ptr, arguments...); } static R unsafeCall(char * ptr, Args... arguments) { C * ptr_typed = static_cast(ptr); return std::invoke(&C::operator(), ptr_typed, arguments...); } };