<div class="gmail_quote">On Fri, Aug 6, 2010 at 11:43, Rory Mcguire <span dir="ltr"><<a href="mailto:rjmcguire@gm_no_ail.com">rjmcguire@gm_no_ail.com</a>></span> wrote:<br><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>I've been trying to make a template for this but it seems that dmd still<br></div>
won't allow me to get the parameters of the constructors. dmd Seems to think<br>
that I'm trying to use it as a property.<br>
<br>
</blockquote><div> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">void main() {<br>
foreach (m; __traits(getOverloads, A, "__ctor")) {<br>
pragma(msg, m.stringof); // it thinks I'm calling m<br>
}<br>
}<br>
<br>
constructors.d(34): Error: constructor constructors.A.this (int x) is not<br>
callable using argument types ()<br></blockquote><div><br>This is my new once-a-day bug :( <br>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!<br>
<br>Anyway, just pragma(msg, m) works, strangely.<br>I think I found a way to use m, somewhat:<br><br>void main() {<br> foreach (m; __traits(getOverloads, A, "__ctor")) {<br> pragma(msg, m); // it thinks I'm calling m<br>
typeof(&m) tmp = &m;<br> writeln( (ParameterTypeTuple!tmp).stringof); // (int), (double), (string)<br> writeln( (ParameterTypeTuple!m).stringof); // (int), (int), (int)<br> writeln( typeof(&m).stringof); // A function(int x), A function(double x), A function(string s)<br>
}<br>}<br><br>using ParameterTypeTuple!m directly does not differentiate the m's. But using a temporary pointer, it seems to work.<br><br>Oh and I even get the arguments names !<br><br><br>Philippe<br><br></div></div>