<div class="gmail_quote">On Mon, Jul 26, 2010 at 00:00, Mafi <span dir="ltr">&lt;<a href="mailto:mafi@example.org">mafi@example.org</a>&gt;</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;">
Am 25.07.2010 14:55, schrieb Philippe Sigaud:<div class="im"><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
OK, I must be tired, I don&#39;t know.<br>
While switching from a template struct to a templated class, I got the<br>
following problem:<br>
<br>
class A(T)<br>
{<br>
     T _t;<br>
     this(U)(U u) if (is(U == T))<br>
     {<br>
         _t = u;<br>
     }<br>
}<br>
</blockquote>
<br></div>
Probably this case is reduced, but anyways:<br>
Having a template(U) where U must be == T (another template parameter) is complettly useless. Maybe I&#39;m missing something but isn&#39;t this equivalent to the above:<div class="im"><br>
class A(T)<br>
 {<br>
      T _t;<br></div>
      this(T u)<br>
      {<br>
          _t = u;<br>
      }<br>
 }<br>
<br>
</blockquote></div><br>Yes, to original case is much more complicated. In fact, it may well be the most complicated template constraint I&#39;ve ever build. It&#39;s five lines long and invoke somthing like four other templates.<br>
<br>It worked for struct A. That&#39;s switching to class A that killed everything :-(<br><br>I&#39;ve a templated Graph struct, templated on Node and Edge (which may very well be templated types themselves, as the user wish). A very handy constructor, invoked by a factory function,  is one taking any number of nodes and edges, checking their compatibility, deducing common properties at compile-time and then constructing the graph.<br>
<br>Philippe<br><br>