get parameters of a function

Alex via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 28 13:43:50 PDT 2017


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() {}
	auto opCall(int i){}	
}

struct S2
{
	auto opCall(int i){}
	auto opCall() {}
}

So, of course, if I change the both opCall methods, e. g. in S1 
it will. But I'm wondering, how to use the trait in this case?

Is it mainly assumed to use it with functions without overloads?


More information about the Digitalmars-d-learn mailing list