<br><br><div class="gmail_quote">On Sun, May 30, 2010 at 17:04, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div id=":jy" class="ii gt">struct Foo(T) {<br>
this(T x) {}<br>
void opCall(U)(U y) {}<br>
}<br>
void main() {<br>
auto foo = Foo!int(1);<br>
foo(1.5);<br>
}</div></blockquote></div><br>I've had this one too. I think it's a bug, because foo is already constructed when foo(1.5) is used. So the compiler should know it's an opCall and not a constructor call.<br>The only solution I found was a kludge:<br>
<br><br>struct Foo(T)<br>{<br> void initialize(T)(T x) {} // in my case, their was some data initialization there.<br> void opCall(U)(U y) {}<br>}<br><br>Foo!T foo(T)() { Foo!T f; f.initialize(); return f;}<br><br>void main() {<br>
auto f = foo(1);<br> f(1.5);<br>}<br><br><br>Philippe<br><br>