How to cast to "void*", while bypassing alias this or opCast

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 28 03:45:51 PDT 2014


I'm investigating a phobos regression. From "doesPointTo":

//----
     static if (isPointer!S || is(S == class) || is(S == 
interface))
     {
         const m = cast(void*) source;
//----

Basically, given a "pointer like" structure, I want the void* 
equivalent. I really don't care about how "S" works, and am 
"observing" the "source" object as nothing more than a bag of 
member fields.

The issue though is that it turns out that such code can and will 
call either opCast or alias this, which is *not* what we want at 
all in this piece of code.

Is there any way to do a "hard" reinterpret cast in such a 
situation?


More information about the Digitalmars-d-learn mailing list