I forget my test context:

void main() {
        alias Vector2D!(short) Vector2s;
        alias Vector2D!(float) Vector2f;
        
        Vector2f vf = Vector2f(23, 42);
        
        Vector2s vs = Vector2s(vf);
        
        writefln("vs.x: %d, vs.y: %d", vs.x, vs.y);
        
        Vector2s vs2 = Vector2s(23, 42);
        
        if (vs2 == vf) {
                writeln("equal");
        }
}

Vector2D is my own class. If i compare vs2 with vs it works fine, but if i compare vs or vs2 with vf, the cast fail and i get a null-reference. How can i avoid this?

Reply via email to