Operator Overloading - Only for Classes and Structs?

Nick Treleaven nick at geany.org
Mon Jun 23 15:31:04 UTC 2025


On Monday, 23 June 2025 at 15:27:46 UTC, Nick Treleaven wrote:
> One reason is that it would be hard to reason about what the 
> operator means - for example if there is one operator overload 
> in module `a` and another one in `b`, that have compatible 
> operand types, and both imports are used in the same project 
> for different modules.

Or rather in the same module.

...
> That is already valid code, because `int` implicitly converts 
> to `dchar`, which can be appended to a string.

Or concatenated, in this case.


More information about the Digitalmars-d-learn mailing list