div0 <d...@users.sourceforge.net> wrote:

This code fails on the line 'int b = f;'. Is it supposed to?


I think so.

'alias this' is used to forward stuff that appears to the right of a dot onto the named member.

Not only. Assignment of the wrapped type will also work.

In c++ to get what you are doing to work, you'd add a customer cast operator:

http://www.digitalmars.com/d/2.0/operatoroverloading.html#Cast

but I'm not sure how the cast operator overloading works in D, I don't know if it will try to implicitly cast and call your operator.

It does not. In WalterAndrei.pdf, opImplicitCast(To|From) is mentioned,
but it has not found its way into the language.

I feel that alias this is currently broken, but hope it will be fixed.

--
Simen

Reply via email to