Closed schveiguy closed 5 months ago
Can you explain more how a better solution would look like? Something like this?
struct Vector2 {
inout T opUnary(string op)() if (op == "+" || op == "-") {
// ...
}
// ...
}
struct Vector3 {
inout T opUnary(string op)() if (op == "+" || op == "-") {
// ...
}
// ...
}
Yes, I want to just replace the mixin with the equivalent code from the operators.
The mixin just obscures what members are on the type, including operator overloads. The mixin also has weird static ifs to prevent overloads on things that it doesn't support, which is exactly backwards.
I'd rather just repeat the correct overloads for each type in the type, not as a template. This also will help IDEs.
Also,
zero
andone
should be enums.