On Fri, Aug 6, 2010 at 11:43, Rory Mcguire <rjmcguire@gm_no_ail.com> wrote:
I've been trying to make a template for this but it seems that dmd still
won't allow me to get the parameters of the constructors. dmd Seems to think
that I'm trying to use it as a property.
void main() {
foreach (m; __traits(getOverloads, A, "__ctor")) {
pragma(msg, m.stringof); // it thinks I'm calling m
}
}
constructors.d(34): Error: constructor constructors.A.this (int x) is not
callable using argument types ()
This is my new once-a-day bug :(
Using a function alias, and being unable to call properties on it, because DMD thinks I'm calling it. Man, it's no property, just a name!
Anyway, just pragma(msg, m) works, strangely.
I think I found a way to use m, somewhat:
void main() {
foreach (m; __traits(getOverloads, A, "__ctor")) {
pragma(msg, m); // it thinks I'm calling m
typeof(&m) tmp = &m;
writeln( (ParameterTypeTuple!tmp).stringof); // (int), (double), (string)
writeln( (ParameterTypeTuple!m).stringof); // (int), (int), (int)
writeln( typeof(&m).stringof); // A function(int x), A function(double x), A function(string s)
}
}
using ParameterTypeTuple!m directly does not differentiate the m's. But using a temporary pointer, it seems to work.
Oh and I even get the arguments names !
Philippe