[Issue 24842] No ability to overload unary logial not operator
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 5 00:01:25 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24842
--- Comment #5 from Mai Lapyst <info at lapyst.by> ---
Thats hardly an reason imho. Because if we use that logic, everybody would
expect `+` to only work on numerical values since it means "addition", jet
it's perfectly fine to do things like this:
```d
struct A {}
struct B {}
struct C {
B opBinary(string op : "+")(A rhs){
return B();
}
}
void main() {
C c;
B b = c + A();
}
```
I would argue that this produces the same "shooting yourself in the foot" as an
overloadable ! operator would.
--
More information about the Digitalmars-d-bugs
mailing list