diff --git a/include/omath/rev_eng/internal_rev_object.hpp b/include/omath/rev_eng/internal_rev_object.hpp index 0270870..9e1bfbb 100644 --- a/include/omath/rev_eng/internal_rev_object.hpp +++ b/include/omath/rev_eng/internal_rev_object.hpp @@ -119,16 +119,28 @@ namespace omath::rev_eng template ReturnType call_virtual_method(auto... arg_list) { - const auto vtable = *reinterpret_cast( + void* sub_this = reinterpret_cast( reinterpret_cast(this) + TableIndex * sizeof(std::uintptr_t)); - return call_method(vtable[Id], arg_list...); + const auto vtable = *reinterpret_cast(sub_this); +#ifdef _MSC_VER + using Fn = ReturnType(__thiscall*)(void*, decltype(arg_list)...); +#else + using Fn = ReturnType(*)(void*, decltype(arg_list)...); +#endif + return reinterpret_cast(vtable[Id])(sub_this, arg_list...); } template ReturnType call_virtual_method(auto... arg_list) const { - const auto vtable = *reinterpret_cast( + const void* sub_this = reinterpret_cast( reinterpret_cast(this) + TableIndex * sizeof(std::uintptr_t)); - return call_method(vtable[Id], arg_list...); + const auto vtable = *reinterpret_cast(sub_this); +#ifdef _MSC_VER + using Fn = ReturnType(__thiscall*)(const void*, decltype(arg_list)...); +#else + using Fn = ReturnType(*)(const void*, decltype(arg_list)...); +#endif + return reinterpret_cast(vtable[Id])(sub_this, arg_list...); } private: