determining if a void* points to a valid Object
Luís Marques
luismarques+spam at gmail.com
Thu Aug 17 15:32:18 PDT 2006
BCS wrote:
> void* ptr;
> // set ptr;
> if(null !is cast(Object)ptr)
> {
> // ptr is an object
> }
>
> This should work because type checking is done on object up cast.
>
> However it dosn't seem to work.
According to my experience, from void* to any type it always works. Only
from Object to subclasses (or among other types, I guess) it actually
does type checking. So if you want to force a cast to another
incompatible classe you can do "cast(OtherClass)cast(void*)".
Luís
More information about the Digitalmars-d
mailing list