<br><br><div class="gmail_quote">On Mon, Apr 19, 2010 at 23:05, Andrei Alexandrescu <span dir="ltr">&lt;<a href="mailto:andrei@erdani.com">andrei@erdani.com</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;">
It&#39;s a good point. Replying to your other point, we need some traits to tell whether something is a built-in float. For those that look like a float, we should define isFloatingPointLike.<br><font color="#888888">
<br>
Andrei</font><div><div></div><div class="h5"><br>
<br>
On 04/19/2010 04:02 PM, Lars Tandle Kyllingstad wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Another point is that if Complex!T is to support arbitrary FP types,<br>
then the trigonometric functions in std.math must too.<br></blockquote></div></div></blockquote><div><br>Hi,<br><br>sorry to interrupt on your conversation (if I can post on the Phobos list), but Lars&#39; comment on CT interfaces got me thinking: is it enough to test the subjacent type with these templates ?<br>
<br>- some type defines some operators (definesOperators!(T, &quot;+&quot;, &quot;-&quot;, ...)<br>- some type can be used with some functions (acceptedBy!(T, &quot;hypot&quot;, ...)<br>- some type can be cast to real. <br>
<br>they could be all easily done, I think.    <br><br>Mostly, it seems to me your code would have a global constraint with struct Complex(T) if (definesOperators!(T, /+ the whole paraphernalia+/)<br><br>And, just around abs and arg, testing if T is accepted by hypot and atan2 _or_ if it can by explicitly cast to a real.<br>
<br>Commenting out abs/arg is enough to get  a Complex!BigInt to compile. <br>but assignment does not work:<br><br>Complex!BigInt c;<br>c = 23; // opAssign asks for a BigInt (R : T)<br>maybe you should ask for something that can be cast to T.<br>
<br>Complex opAssign(R)(R r) if (__traits(compiles, {T t; R r; t=r;} ))<br>    {<br>        re = r;<br>        im = 0;<br>        return this;<br>    }<br><br>Philippe<br><br></div></div>