cast(size_t)&c != 0, but c is null
Steven Schveighoffer
schveiguy at yahoo.com
Wed May 15 11:30:49 PDT 2013
On Wed, 15 May 2013 11:08:33 -0400, Artur Skawina <art.08.09 at gmail.com>
wrote:
> On 05/15/13 13:04, Dicebot wrote:
>> On Wednesday, 15 May 2013 at 10:31:29 UTC, David wrote:
>>>> "&c" is address of reference, no class instance. I don't know if there
>>>> is a way to get a pointer to class instance in D but I am not aware
>>>> of one.
>>>
>>> A simple cast to void* should do it: cast(void*)c
>
> class C { auto opCast(T:void*)() { return null; } }
>
> So - no - a simple cast to void* won't always work, as the op can be
> overloaded, even if only by accident.
You can insert a cast to Object first.
-Steve
More information about the Digitalmars-d-learn
mailing list