Generic Math Interfaces and Container Issues #5809
-
Generic math is a great step forwards the way it is done with interfaces comes with some issues especially when creating containers like The only way I can currently think of that would allow this to work would require 2 other features to be implemented first. First one being additional type restrictions on methods similar to how extension methods allow it eg: It would be great if there was a way to support this behavior in some way. Also I feel like the current approach could potentially create issues in the future when adding support for something like this |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Extensions might be able to solve this #5497 E.g. extension AddableVector<T> for Vector<T> : IAddable<AddableVector<T>> where T : IAddable<T>
{
// Impl goes here
} |
Beta Was this translation helpful? Give feedback.
-
In practice, the examples given work fine if some conventions are adopted. For example bool maps to 0/1 or integers behave like floats which are truncated/rounded. Are there examples where this causes bigger problems? |
Beta Was this translation helpful? Give feedback.
Extensions might be able to solve this #5497
E.g.