Re: Verifying the arguments of a function with ref parameters?
On Thursday, 28 July 2016 at 21:49:00 UTC, pineapple wrote: On Thursday, 28 July 2016 at 20:28:39 UTC, jdfgjdf wrote: "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" What would be a better way to check whether some callable can be called using a parameters tuple? Oh, I answered my own question enum bool dgrefcallable = is(typeof((){auto params = Parameters!dgref.init; dgref(params);}));
Re: Verifying the arguments of a function with ref parameters?
On Thursday, 28 July 2016 at 20:28:39 UTC, jdfgjdf wrote: "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" What would be a better way to check whether some callable can be called using a parameters tuple?
Re: Verifying the arguments of a function with ref parameters?
On Thursday, 28 July 2016 at 21:49:00 UTC, pineapple wrote: On Thursday, 28 July 2016 at 20:28:39 UTC, jdfgjdf wrote: "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" What would be a better way to check whether some callable can be called using a parameters tuple? http://dlang.org/phobos/std_traits#.lvalueOf
Re: Verifying the arguments of a function with ref parameters?
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"
Verifying the arguments of a function with ref parameters?
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!