forward references... again?

Mehrdad wfunction at hotmail.com
Mon Sep 26 10:13:01 PDT 2011


On 9/26/2011 9:36 AM, bearophile wrote:
> In similar situations I suggest you to minimize your code, so both you 
> ans us are able to better see the situation and the problem. Doing 
> that you often don't need help. Bye, bearophile 
Hope this is better:

void main() {
     (Test() + Test()).get(0.0);
}

struct Sum(T1, T2) {
     T1 a;
     T2 b;

     auto ref get(T2...)(T2 args) {
         return (a + b).get(args);  // Why is calling get() considered a 
"forward reference"?
     }
}

struct Test {
     auto ref get(T2...)(T2 value) { return 0; }

     Sum!(typeof(this), T2) opAdd(T2)(T2 other) const {
         return typeof(return)(this, other);
     }
}



More information about the Digitalmars-d mailing list