ptrdiff_t of class.tupleof entry
Satoshi via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 10 10:57:15 PDT 2016
Hello,
How can I take an ptrdiff_t of any tupleoff entry from class
during compilation?
I need something like this:
template Test(T, int i) {
enum Test = &T.tupleof[i] - &T.tupleof[0];
}
and then use it like:
class AnyClass {
int a;
int b;
int c;
string d;
}
enum Addr = Test!(AnyClass, 3);
void assignInt!(T)(AnyClass cls, T value) {
*(cast(T *)cast(void *)cls + Addr) = value;
}
This is just an example how I need to use it.
Is something like this possible to do?
More information about the Digitalmars-d-learn
mailing list