Greetings All

Can you help me with this code? I could not find any traits or other way to get me outer object of a given inner object. As for the context, I am fiddling with D trying to write a (domain specific) generic baseclass library. InnerBase is part of the library I write and the end user would be coding Outer and Inner classes. I do not want to force him to write getOuter kind of function. I would prefer not to ask him to add a mixin as well.

Is that possible, or is forcing the user to add a mixin the only way out?

Regards
- Cherry

////////////////////////////////////////////////////

class InnerBase{}
class Outer {
  class Inner: InnerBase {}
}
void main() {
  Outer outer = new Outer;
  auto inner = outer.new Outer.Inner();
  foo(inner);
}
void foo(T)(T t) {
  // somehow access inner.outer -- inner -> this.outer
// Can not change Inner class to introduce getOuter functionality
  // I have access to InnerBase though and can add code there
}

Reply via email to