inner member classes in final outer class

coxalan coxalan at web.de
Sun Sep 16 08:49:41 PDT 2007


Matti Niemenmaa Wrote:

> coxalan wrote:
> > Bruno Medeiros Wrote:
> > 
> >> I was thinking the following:
> >>
> >>    class Outer {
> >>    }
> >>
> >>    class Inner(alias outer) {
> >>      static assert(is(outer : Outer)); // Just a check
> >>    }
> >>
> >>    final Outer o1 = new Outer();
> >>    final Outer o2 = new Outer();
> >>
> >>    void main() {
> >>        Inner i1 = new Inner!(o1);
> >>        Inner i2 = new Inner!(o1);
> >>
> >>        Inner i3 = new Inner!(o2);
> >>        Inner i4 = new Inner!(o2);
> >>    }
> > 
> > Thanks. That looks quite promising.
> > 
> > But it does not compile for me:
> > test.d(12): class test.Inner(alias outer) is used as a type
> > test.d(12): variable test.main.i1 voids have no value
> 
> Probably because he uses "Inner i[1234]" where he should use "Inner!(o[1234])
> i[1234]". The easiest solution is to use "auto" on the left-hand side of the
> assignments.

Thanks. Now I get:
test.d(5): static assert  is false

Disclaimer: I'm quite new to D.

coxalan



More information about the Digitalmars-d mailing list