Hello,
why operator overloading is not working as a static methods through the UFCS?

I need overload a << operator in this way:

enum PlatformID {
        None,
        Trinix,
        Unix,
        MacOS,
        Windows
}

PlatformID toPlatformID(string platform) {
        switch (platform.toLower()) {
                case "trinix":  return PlatformID.Trinix;
                case "unix":    return PlatformID.Unix;
                case "macos":   return PlatformID.MacOS;
                case "windows": return PlatformID.Windows;
                default:        return PlatformID.None;
        }
}

void opBinary(string op)(ref PlatformID plat, auto ref const string str) if (op == "<<") {
        plat = toPlatformID(str);
}


void thisIsTest() {
        PlatformID id;
        id << "x86_64"; // this is not working
        id.opBinary!("<<")("test"); // but this works O.K.

}

Reply via email to