is there any reason UFCS can't be used with 'new'?
Jay via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Sep 28 13:28:10 PDT 2014
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);
> }
> }
fwiw here's what i wrote:
template New(T) if (is(T == class)) {
T New(Args...) (Args args) {
return new T(args);
}
}
...
New!Bar("hi").txt.writeln;
not as neat as your version but still improves on the ugly (new
Class()).method syntax and doesn't need to be mixed into the
class definition.
More information about the Digitalmars-d-learn
mailing list