By making the operators on quantity templates:<div><div>ref Quantity opAssign(U)( Quantity!(U) u2 ) {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>static assert( SameUnit!(U,Unit) );</div><div><span class="Apple-tab-span" style="white-space:pre">  </span>this.value = u2.value;</div>
<div><span class="Apple-tab-span" style="white-space:pre">      </span>return this;</div><div>}</div><div><br></div><div>Same for addition, subtraction and equality. Multiplication and division will have to have a different return type.</div>
<div>Seems right to me, am I missing something?</div><br><div class="gmail_quote">On 30 March 2011 00:39, David Nadlinger <span dir="ltr"><<a href="mailto:see@klickverbot.at">see@klickverbot.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On 3/30/11 12:20 AM, Cristi Cobzarenco wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Well they don't _have_ to be the same type as long they're convertible<br>
to one another, and one can make sure they're convertible based on the<br>
result of the double-inclusion.<br>
</blockquote>
<br></div>
But how would you make them _implicitly_ convertible then?<br><font color="#888888">
<br>
David<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>(Cristi Cobzarenco)<br>Pofile: <a href="http://www.google.com/profiles/cristi.cobzarenco">http://www.google.com/profiles/cristi.cobzarenco</a><br>
</div>