Replacement for C++ Style Implicit casts?

Mike Chaten mchaten at gmail.com
Tue Oct 19 07:29:48 PDT 2010


Thanks for all your help!

-Mike

On Mon, Oct 18, 2010 at 6:21 PM, Simen kjaeraas <simen.kjaras at gmail.com>wrote:

> Mike Chaten <mchaten at gmail.com> wrote:
>
>  I was under the impression that alias this just was shorthand for
>> Class Foo {
>> int x;
>> alias x this;
>> }
>> Foo foo =  new Foo
>> foo = 9; // foo.x = 9
>> Foo Foo = 9 // null.x =9;
>>
>
> Not just. this would also work:
>
> int n = foo;
> // void bar( int n ) {}
> bar( foo );
>
>
>
>  Also, for opCast, doesnt that only work for going from Foo to int and not
>> the other way around?
>>
>
> Indeed. For implicit casts to Foo, I don't know what, if anything, works.
>
> void baz( Foo f ) {}
> baz( 3 ); // How?
>
> Likely, there is no such functionality in D, at least for the moment.
>
> --
> Simen
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20101019/77eea3d0/attachment.html>


More information about the Digitalmars-d-learn mailing list