[Issue 24039] New: Provide operator overload members for built-in types
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 7 13:48:52 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24039
Issue ID: 24039
Summary: Provide operator overload members for built-in types
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: qs.il.paperinik at gmail.com
For user-defined types, if `a + b` works, it’s because `typeof(a)` has
`opBinary` and `a.opBinary!"+"(b)` compiles, or `typeof(b)` has `opBinaryRight`
and `b.opBinaryRight!"+"(a)` compiles. (If both are present, it seems
`opBinaryRight` is preferred.
If both are built-in types, there are no `opBinary` or `opBinaryRight`, as well
as other operators such as `opEquals` and `opCmp`.
It would make meta-programming a lot easier if one wouldn’t have special-case
built-in types and those operator (member) functions would Just Work.
For some cases, they could even be defined in object.d as free functions, but
it would be ideal if the compiler just pretended that those types had the
operator member functions.
--
More information about the Digitalmars-d-bugs
mailing list