C++ cast to D cast Part 2
BLS
nanali at nospam-wanadoo.fr
Sun Sep 23 12:52:51 PDT 2007
Jarrett Billingsley schrieb:
> "Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message
> news:fd3tfr$8i6$2 at digitalmars.com...
>> Jarrett Billingsley wrote:
>>> "BLS" <nanali at nospam-wanadoo.fr> wrote in message
>>> news:fd2v57$1ueb$1 at digitalmars.com...
>>>
>>>> CWin pActive = cast(CWin)cast(void*)
>>>> cast(HWND)GetWindowLong(msg.hwnd,GWL_USERDATA);
>>> Yessir.
>> Yes that's what I meant, but I have no idea if it works. It was just a
>> guess. Jarrett you can confirm that that avoids the runtime check in the
>> cast?
>>
>> --bb
>
> class A
> {
>
> }
>
> class B
> {
>
> }
>
> void main()
> {
> A a = new A();
> B b = cast(B)cast(void*)a;
> B b2 = cast(B)a;
>
> Stdout.formatln("{:X8} {:X8}", cast(void*)b, cast(void*)b2);
> }
>
> This prints out (something like)
>
> 0012AB60 00000000
>
> So yes, the cast(B)cast(void*) avoids a runtime check.
>
>
Thanks !
Jarret, do you see a chance to place your solution, as well as comments at
http://www.prowiki.org/wiki4d/wiki.cgi?PortingOverview
Porting Code from C++ to D
(Hope I am not asking for too much, but the more you are going into
details the more ... You know :)
Bjoern
More information about the Digitalmars-d-learn
mailing list