Verifying the arguments of a function with ref parameters?

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 28 12:19:06 PDT 2016


Why doesn't this code do what I'd expect it to, and how can I fix 
it?

     unittest{
         import std.traits : Parameters;
         // Works as expected
         alias dg = int delegate(int value);
         enum bool dgcallable = 
is(typeof((){dg(Parameters!dg.init);}));
         pragma(msg, dgcallable); // Prints true
         // Doesn't work as expected
         alias dgref = int delegate(ref int value);
         enum bool dgrefcallable = 
is(typeof((){dgref(Parameters!dgref.init);}));
         pragma(msg, dgrefcallable); // Prints false
     }

Thanks!


More information about the Digitalmars-d-learn mailing list