Inner Classes vs. Inner Structs
Mike Franklin
slavo5150 at yahoo.com
Sun Mar 11 13:19:39 UTC 2018
This works:
```
class S {
int n, m;
int sum() { return n + m; }
Inner!(sum) a;
class Inner(alias f){
auto get() {
return f();
}
}
}
```
This doesn't:
```
struct S {
int n, m;
int sum() { return n + m; }
Inner!(sum) a;
struct Inner(alias f){
auto get() {
return f(); // Error: this for sum needs to be type S
not type Inner!(sum)
}
}
}
```
The only difference between the two is one one uses classes, the
other uses structs. My question is, under the current semantics
of D, shouldn't the two work the same? That is, shouldn't the
inner struct in the second example have an implicit context
reference to the outer struct? Is this a bug?
Thanks for the help,
Mike
More information about the Digitalmars-d-learn
mailing list