On 9/20/21 6:16 PM, rjkilpatrick wrote:
Essentially, I would like to write a template that calls the constructor
of the parent class or the constructor of the inherited class, depending
on its type.
...
Some kind of `return new this(...)` would be good, but that's not possible.
I think it
On Monday, 20 September 2021 at 22:16:47 UTC, rjkilpatrick wrote:
auto opBinary(string op)(int rhs) const if (op == "+") {
return new Super(_a + rhs); // Creates of type Super
even when called from derived class
}
Make this
auto opBinary(string op, this This)(int rhs)
Essentially, I would like to write a template that calls the
constructor of the parent class or the constructor of the
inherited class, depending on its type.
```d
#!/usr/bin/env dub
/+ dub.sdl:
name "mwe"
+/
class Super {
private int _a;
this(){}
this(int a) {
_a =