inner member classes in final outer class
coxalan
coxalan at web.de
Thu Sep 20 06:52:26 PDT 2007
Matti Niemenmaa Wrote:
> Alright, I took a closer look and this compiles:
>
> class Outer {
> }
>
> class Inner(alias outer) {
> static assert(is(typeof(outer) : Outer)); // Just a check
> }
>
> final Outer o1;
> final Outer o2;
>
> static this() {
> o1 = new Outer;
> o2 = new Outer;
> }
>
> void main() {
>
> auto i1 = new Inner!(o1);
> auto i2 = new Inner!(o1);
>
> auto i3 = new Inner!(o2);
> auto i4 = new Inner!(o2);
> }
>
> --
> E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi
One last question on this:
Is it possible to do the same with D version 1?
The current code comples with DMD v2.004, but with DMD 1.020 I get:
forum.d(16): Error: cannot modify final variable 'o1'
forum.d(17): Error: cannot modify final variable 'o2'
coxalan
More information about the Digitalmars-d
mailing list