On Monday, 6 May 2019 at 16:50:14 UTC, Robert M. Münch wrote:
        myFramework mf = new myFramework;

I'd make that thing's constructor private, and then offer a helper template function that actually creates it and the user passes a type.

---
// inside your library
struct myFramework {
   private MyFramework app;
   private this(MyFramework app) {
      this.app = app;
   }
}

myFramework initializeMyFramework(FrameworkClass)() if(is(FrameworkClass : myFrameworkApp))
{
    return myFramework(new FrameworkClass());
}
---

Then the user's code would look something like this:

---
import my_framework;
class myAppCode : myFrameworkApp {
    // implementations....
}

void main() {
   auto thing = initializeMyFramework!myAppCode;
   // if you have other stuff to do with thing, you can here.
}
---

Reply via email to