Address of return value.

monarch_dodra monarchdodra at gmail.com
Tue Dec 11 06:57:26 PST 2012


I feel incredibly stupid asking this one, but how does one 
extract the address of return value of a member function that 
returns by ref?

Case in point:

//----
struct S
{
     int i;
     ref front() @property
     {
         return i;
     }
}

void foo(int*){}

void main()
{
     auto s = S();
     static assert (hasLvalueElements!S);
     auto p = &(s.front);
     writeln(typeof(p).stringof); //produces int delegate() 
@property ref
     foo(p);
}
//----
Error: function main.foo (int* _param_0) is not callable using 
argument types (int delegate() @property ref)
Error: cannot implicitly convert expression (p) of type int 
delegate() @property ref to int*
//----
I want: the address of the value returned by s.front.
I get: the address of the function S.front.

:/


More information about the Digitalmars-d-learn mailing list