What is best way to get equivalent of C++ private inheritance combined with using declarations in the drived to expose some functionality. For example, suppose I want a basic RateCurve class that defers almost entirely to type Array as below. The problem is, once RateCurve is moved to a different module, the private impl prevents it from working:

Thanks
Dan

----------
module play.m.x;
import std.stdio;
import std.container;
import std.datetime;

struct DateValue {
   Date date;
   double value;
}

struct RateCurve {
  alias Array!DateValue Impl;
  alias impl this;

  // I am a Array!DateValue, so I can do:
  double getRate(Date d) {
    // access myself to get a rate...
    return 0;
  }

public: // If this is private it is a problem!!! How to fix?
  Impl impl;
}
----------
import std.stdio;
import std.datetime;
import play.m.x;

void main() {
  static if(0) {
    // Support for following would be great
    auto rc = RateCurve(DateValue(Date(2001,1,1), 0.2),
                        DateValue(Date(2002,1,1), 0.25));
  } else {
    auto rc = RateCurve();
  }
  rc.insert(DateValue(Date(2001,1,1), 0.2));
  // indexing
  writeln("Initial rate is ", rc[0]);
  auto someDate = Date(2001,6,1);
  auto rate = rc.getRate(someDate);
  foreach(r; rc) {
    writeln("on ", r.date, " rate is ", r.value);
  }
}
----------

Reply via email to