Transparent cast from class to member pointer?

Robert M. Münch robert.muench at saphirion.com
Sun Apr 14 18:03:49 UTC 2019


struct IM;
struct C {
  IM *impl;
};

int cInit(C* self);

class I {
	C handler;

	this(){cInit(&handler);}
}

Is there a simple way that I can use handler without the address-of 
operator and automatically get *impl?

Something like:

class I {
	C handler;

	this(){cInit(handler);}
}

And later can use I in a way like this without having to define/write 
explicit casts everywhere?

someFunc(C* self);

I myI;
someFunc(myI);


-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list