is there any reason UFCS can't be used with 'new'?
    "Nordlöw" via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Sep 30 10:35:32 PDT 2014
    
    
  
On Sunday, 28 September 2014 at 20:28:11 UTC, Jay wrote:
> fwiw here's what i wrote:
>
> template New(T) if (is(T == class)) {
>     T New(Args...) (Args args) {
>         return new T(args);
>     }
> }
My try
template New(T) if (is(T == class))
{
     T New(Args...) (Args args) {
         return new T(args);
     }
}
unittest
{
     class C { int x, y; }
     auto x = New!C;
}
fails as
typecons_ex.d(60,16): Error: outer function context of 
typecons_ex.__unittestL64_4 is needed to 'new' nested class 
typecons_ex.__unittestL64_4.C
typecons_ex.d(67,14): Error: template instance 
typecons_ex.New!(C).New!() error instantiating
    
    
More information about the Digitalmars-d-learn
mailing list