introspection/name: add member_offset query for pointer-to-member

This commit is contained in:
Danny Robson 2021-04-07 12:53:19 +10:00
parent de1d9649a3
commit 6ba13aa25e

View File

@ -168,6 +168,15 @@ namespace cruft::introspection::name {
} }
constexpr std::size_t
member_offset (auto ptr)
{
using klass_t = typename pointer_to_member_class<decltype (ptr)>::type;
klass_t instance {};
return std::uintptr_t (&(instance.*ptr)) - std::uintptr_t (&instance);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
template <typename T> template <typename T>
struct type_char; struct type_char;