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 04:32:15 PDT 2014
On Thursday, 28 August 2014 at 11:02:03 UTC, anonymous wrote:
> On Thursday, 28 August 2014 at 10:45:52 UTC, monarch_dodra
> wrote:
>> 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?
>
> *cast(void**)&source
Hum... now I feel retarded.
In my mind I had "I want re-interpret, not address of, so no
operator&".
Thanks.
More information about the Digitalmars-d-learn
mailing list