On 06/29/2018 02:11 PM, Timoses wrote:

> .... How would one print the address of the object then though?
> Since &a is the address of the reference' types stack location.

Casting the reference to void* produces the address of the object:

import std.stdio;

class C {
    int i;
}

void main() {
    auto r = new C();
    writeln("Reference is at ", &r);
    writeln("Object is at    ", cast(void*)r);
    writeln("Member is at    ", &r.i);
}

Sample output:

Reference is at 7FFE735E6698
Object is at    7F78F02B0060
Member is at    7F78F02B0070

Ali

Reply via email to