thanks! but i'm still interested *why* you can't have this with 'new'. if there's no good reason i will file a bug report.

On Sunday, 28 September 2014 at 19:19:56 UTC, Foo wrote:
mixin template New(T) if (is(T == class)) {
        static T New(Args...)(Args args) {
            return new T(args);
        }
}

class Bar {
        string txt;
        
        this() {
                txt = "Foo";
        }
        
        this(string t) {
                txt = t;
        }
        
        mixin New!Bar;
}

void main() {
        import std.stdio;
        
        writeln(Bar.New().txt);
        writeln(Bar.New("Bar").txt);
}

Reply via email to