Some questions now D2 is frozen

Michel Fortin michel.fortin at michelf.com
Sun Feb 21 06:39:54 PST 2010


On 2010-02-21 08:56:14 -0500, Philippe Sigaud <philippe.sigaud at gmail.com> said:

> Anyway, I just tried:
> 
> class C {
> 
>    alias opImplicitCast this;
> 
>    @property int opImplicitCast() { return 1;}
> }
> 
> auto c = new C();
> int foo(int a) { return a;}
> 
> foo(c); // error. function main.foo (int a) is not callable using argument
> types (C)
> auto i = cast(int)c; // This works, but I'd call that explicit cast...
> 
> I'm doing something wrong there? Is calling foo on c an implicit cast?

I was using this to implicitly convert to an Object. Seems it does not 
work for an int.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list