On Sun, Sep 9, 2012 at 5:16 PM, Nick Treleaven <[email protected]> wrote:
> Maybe you could use a template:
>
> auto create(T, Args...)(Args args)
> {
> return new T(args);
> }
>
> class A
> {
> int i;
> this(int i){this.i = i;}
> }
>
> import std.stdio;
>
> void main()
> {
> create!A(5).i.writeln();
> }
A generic 'create' template would be good for generic code: on a
reference type, use 'new' and pass args, whereas for a value type, use
the type directly. Of course, this should manage builtins (like int,
int[], int[3]) correctly.