forward references... again?
Jonathan M Davis
jmdavisProg at gmx.com
Mon Sep 26 10:56:58 PDT 2011
On Monday, September 26, 2011 10:13 Mehrdad wrote:
> 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);
> }
> }
I'm not sure, but I would have expected that reusing T2 in th template of the
get function would cause problems. At best, that T2 is shadowing the outer T2.
You should be using a different name for get's template parameter. Maybe that
has something to do with the problem, and the error message is just bad.
- Jonathna m Davis
More information about the Digitalmars-d
mailing list