Bug 24569 – operator overloading on pointer to value-type instances

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-05-27T10:48:57Z
Last change time
2024-12-13T19:35:25Z
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#20459 →

Comments

Comment #0 by b2.temp — 2024-05-27T10:48:57Z
Maybe this should work ```d struct S { void opOpAssign(string op, T)(T t) { } } void main() { S a; a ~= 0; // OK auto b = &a; b.opOpAssign!"~"(0); // OK b ~= 0; // NG, but maybe should ? } ``` The idea is that usually member functions are supposed to work on pointers to instances implementing these functions.
Comment #1 by dkorpel — 2024-05-27T14:37:01Z
Pointers already overload most operators (pointer arithmetic and slicing), so I don't think it's good practice to depend on overloading the remaining ones. Do you have a real type in use where you want to overload concatenation but keep pointer indexing?
Comment #2 by robert.schadek — 2024-12-13T19:35:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20459 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB