Some problems with operator overloading

Philippe Sigaud philippe.sigaud at gmail.com
Mon Mar 15 14:55:12 PDT 2010


On Mon, Mar 15, 2010 at 16:12, Steven Schveighoffer <schveiguy at yahoo.com>wrote:

(On alias this)

> Yeah, I tried to get it to work too, but it doesn't.  Even something like
> this doesn't work:
>
> struct Foo {
>   uint x;
>   uint castToUint() { return x; }
>   alias castToUint this;
> }
>
> This should work.  The template code you wrote above might not work,
> because you can't overload functions on no arguments.  I'm unsure how this
> should work, but at least something like this should:
>
> alias opCast!uint this;
>
> A bug filing is in order I think.
>

I never got 'alias this' to work. Regularly, someone posts some cool
possible code here, and I can't get it to compile :(
And IIRC, you can have only one alias this in an object, which somewhat
limits its usefulness.

Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100315/8afacde5/attachment.html>


More information about the Digitalmars-d mailing list