|
|
|
|
|
by scatters
2026 days ago
|
|
Rather than storing the offset within the struct, you could store a type-erased pointer to data member: struct M {
std::byte M::*p;
std::size_t l;
template<class C, class T>
M(T C::*e) : p{reinterpret_cast<std::byte M::*>(e)}, l{sizeof(T)} {}
};
Also there are ways (not necessarily legal) to convert a pointer to data member to an offset; see the proposal http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p090... |
|