File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020
2121namespace DynLibUtils {
2222
23- template <auto METHOD>
23+ template <typename F, F METHOD>
2424constexpr std::ptrdiff_t GetVirtualIndex () noexcept
2525{
26- static_assert (std::is_member_function_pointer_v<decltype (METHOD) >, " Templated method must be a pointer-to-member-function" );
26+ static_assert (std::is_member_function_pointer_v<F >, " Templated method must be a pointer-to-member-function" );
2727
2828 // --- Itanium C++ ABI: PMF.ptr = 1 + offset_in_bytes for virtual ones ---
2929 struct ItaniumPMF
@@ -36,7 +36,7 @@ constexpr std::ptrdiff_t GetVirtualIndex() noexcept
3636
3737 std::ptrdiff_t adj;
3838 };
39- constexpr union { decltype (METHOD) m; ItaniumPMF pmf; } u{ METHOD };
39+ constexpr union { F m; ItaniumPMF pmf; } u{ METHOD };
4040
4141#if defined(_MSC_VER)
4242 auto *pAddr = reinterpret_cast <unsigned char *>(u.pmf .ptr );
@@ -129,6 +129,7 @@ constexpr std::ptrdiff_t GetVirtualIndex() noexcept
129129
130130 return DYNLIB_INVALID_VCALL;
131131}
132+ template <auto METHOD> constexpr std::ptrdiff_t GetVirtualIndex () noexcept { return GetVirtualIndex<decltype (METHOD), METHOD>(); }
132133
133134// Provides an interface to manipulate and invoke entries from a class's virtual table (vtable).
134135class CVirtualTable
You can’t perform that action at this time.
0 commit comments