On 18 November 2012 14:01, David Nadlinger <span dir="ltr"><<a href="mailto:see@klickverbot.at" target="_blank">see@klickverbot.at</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sunday, 18 November 2012 at 11:21:37 UTC, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
someFloat = someHalf <- doesn't work, because a cast operator expects an<br>
explicit cast, even though this is a lossless conversion and should be<br>
exactly the same as someDouble = someFloat.<br>
<br></div>
Thoughts?<br>
</blockquote>
<br>
---<br>
struct Half {<br>
float toFloat() { return 3.14f; }<br>
alias toFloat this;<br>
}<br>
<br>
void test() {<br>
Half h;<br>
float f = h;<br>
double d = h;<br>
}<br>
---<br>
<br>
Works for you?</blockquote><div><br></div><div>Interesting approach to the implicit cast problem. Very handy trick.</div></div></div>