I am writing my data structure: type MyContainer[constraints.Ordered] {… }
Sadly it can take ints, floats, any primitive data type, but not a custom struct that has Less and Equal implemented.
This forces me to choose: either my payload (what I insert in MyContainer) is a primitive data type, or a struct.
Any idea on how I can bypass this ? I want MyContainer to be able to store both (same generic code can be instantiated either for a primitive data type or a custom struct).
Inside MyContainer, I want to be able to add ints, floats, strings (anything in constraints.Ordered). But I also want my same code to work for any struct that implements type MyInterface { Less(MyInterface) bool}
Another issue: I cannot help but notice with weakness of generics, if you instantiate MyContainer with ints, and you want to inserts a float into it, it will not work. Similarly, if you instantiate a MyContainer with MyStructA, then you cannot insert an object of type MyStructB in it, even though MyStructB implements the same interface as MyStructA. Please advice on how to bypass this as well.