<br><br><div class="gmail_quote">On Sun, Feb 21, 2010 at 14:34, Michel Fortin <span dir="ltr"><<a href="mailto:michel.fortin@michelf.com">michel.fortin@michelf.com</a>></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;">
<div class="im">On 2010-02-21 08:28:02 -0500, Philippe Sigaud <<a href="mailto:philippe.sigaud@gmail.com" target="_blank">philippe.sigaud@gmail.com</a>> said:<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Another thing I'd be very happy to have is opImplicitCast....<br>
</blockquote>
<br></div>
I think this works already:<br>
<br>
alias opImplicitCast this;<br>
<br>
@property T opImplicitCast() { ... }<font color="#888888"><a href="http://michelf.com/" target="_blank"></a></font></blockquote><div><br>Hmm, I'm still a bit leery of 'alias this' as all my uses for it misfired. But if that works, then, being an obnoxious brat, I will ask for the possibility to have many 'alias this' in the same object :-)<br>
<br>Anyway, I just tried:<br><br>class C {<br><br> alias opImplicitCast this;<br>
<br>
@property int opImplicitCast() { return 1;}<br>}<br><br>auto c = new C();<br>int foo(int a) { return a;}<br><br>foo(c); // error. function main.foo (int a) is not callable using argument types (C)<br>auto i = cast(int)c; // This works, but I'd call that explicit cast...<br>
<br>I'm doing something wrong there? Is calling foo on c an implicit cast?<br></div></div><br>