I'll add just for info sake even though you can just use normal gc in your own constructors as wanted, other options include:

1) making a buffer inside your new object and copying the message to it, then passing a slice of your buffer to the super ctor.

2) making all the messages compile-time literals so each class has a static message. then there's no runtime work at all. (and you can differentiate things based on type!)

can even be defined inline like

`throw new NotImplemented!"thing"`

and then the impl is like

class NotImplementedBase : Exception {
  mixin ExceptionCtors;
}

class NotImplemented(string msg) : NotImplmentedntedBase {
   this() { super ("Not implemented" ~ msg); }
}


that kind of thing just plus the file line info etc too arguments.

3) ignore hte msg member and just override toString



But again the base ctor limitations do NOT apply to derived classes so it is all moot.


btw for virtual interfaces base things do apply but you're allowed to tighten if you want. so like base toString is NOT @nogc but if you wanted derived @nogc that's perfectly allowed. virtual methods must be as strict or stricter since they're inherited. just again ctors are not inherited so there's no connection at all.

Reply via email to