Reset all Members of a Aggregate Instance
Chris Wright via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 7 21:13:51 PST 2015
On Tue, 08 Dec 2015 14:12:02 +1100, Daniel Murphy wrote:
> On 4/12/2015 8:38 AM, Chris Wright wrote:
>> An object reference is just a pointer, but we can't directly cast it.
>> So we make a pointer to it and cast that; the type system allows it.
>> Now we can access the data that the object reference refers to
>> directly.
>
> Casting is fine too: cast(void*)classRef
Amazing. I assumed that this wouldn't be allowed because it's not exactly
nice to the type system, but apparently you can cast anything but a user-
defined value type to void*. Bool, dchar, associative arrays, normal
arrays, the good void* casts them all.
More information about the Digitalmars-d-learn
mailing list