Re: get parameters of a function

2017-04-29 Thread Alex via Digitalmars-d-learn
On Saturday, 29 April 2017 at 08:15:06 UTC, Stanislav Blinov wrote: Ah, that calls for something like a isCallableWith template. Pay extra care to how you pass parameters in that variadic opCall template though. Doing it like in the code above will pass everything by value, even though the

Re: get parameters of a function

2017-04-29 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 29 April 2017 at 06:18:34 UTC, Alex wrote: The problem is another one: say I have something like this: import std.traits; struct A(alias T) if(isCallable!T) { auto opCall(U...)(U args) if(is(Parameters!T == U)) //if(__traits(compiles, T(args))) {

Re: get parameters of a function

2017-04-29 Thread Alex via Digitalmars-d-learn
On Saturday, 29 April 2017 at 05:58:35 UTC, Stanislav Blinov wrote: On Friday, 28 April 2017 at 20:43:50 UTC, Alex wrote: void main() { foreach(o1; __traits(getOverloads, S1, "opCall")) { alias P1 = Parameters!o1; foreach(o2; __traits(getOverloads, S2, "opCall"))

Re: get parameters of a function

2017-04-29 Thread Stanislav Blinov via Digitalmars-d-learn
On Friday, 28 April 2017 at 20:43:50 UTC, Alex wrote: Hi all, I have a question about the Parameters trait from https://dlang.org/phobos/std_traits.html#Parameters The following code does not compile. Why? Is it mainly assumed to use it with functions without overloads? Rather, it is to be

get parameters of a function

2017-04-28 Thread Alex via Digitalmars-d-learn
Hi all, I have a question about the Parameters trait from https://dlang.org/phobos/std_traits.html#Parameters The following code does not compile. Why? import std.traits : Parameters; void main() { static assert(is(Parameters!S1 == Parameters!S2)); } struct S1 { auto opCall()