<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 24 July 2014 16:22, Daniel Murphy via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">"Manu via Digitalmars-d" <<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>> wrote in message news:mailman.243.1406177619.<u></u>32463.digitalmars-d@puremagic.<u></u>com...<br>

<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">
The other case I am running in to is when I have 'struct S(T)' or 'class C(T)', where T > can be inferred from the constructor, but it isn't.<br>
<br></div><div class="">
struct S(T)<br>
{<br>
  this(T t)<br>
  {<br>
    m = t;<br>
  }<br>
<br>
  T m;<br>
}<br>
</div></blockquote>
<br>
Infer this:<br>
<br>
struct S(T)<br>
{<br>
   static if (is(T == int))<br>
       this(float x) {}<br>
   static if (is(T == float))<br>
       this(int x) {}<br>
} <br>
</blockquote></div><br></div><div class="gmail_extra">I imagine that would be a compile error; the static if can't be resolved without knowing T, and prior to resolution of the static if, no constructors exist.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Also, the constructor args don't reference T anyway, so I see no reason why it would ever want to try and deduce T in this situation.</div><div class="gmail_extra">
In my example, the constructor implies T, in your example, T implies the constructor... it doesn't make logical sense the way you present.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">
Personally, I wouldn't want the compiler to attempt to deduce T in this case you present, even if it were theoretically possible. It looks like the programmer intended something very specific in this case. I'd rather have compile errors when I pass incorrect things to explicit argument types.</div>
</div></div>