Verifying the arguments of a function with ref parameters?
jdfgjdf via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 28 13:28:39 PDT 2016
On Thursday, 28 July 2016 at 19:19:06 UTC, pineapple wrote:
> 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!
"Parameters!dgref.init" does not yield a reference. The real
error is not displayed. In a normal context it would be "stuff is
not callable with...."
More information about the Digitalmars-d-learn
mailing list