[Issue 9249] Defining opCast disables Upcasting

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 10 20:41:01 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9249


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-10 20:40:57 PST ---
What your sample is showing is downcasting, this is upcasting:

class C1
{
    public T opCast(T)()
        if (is(T == string))
    {
        return "C1";
    }
}

class C2 : C1
{
}

void main()
{
    C2 c2;
    C1 c1 = cast(C1)c2;
}

Both fail though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list