operator overloading outside the type

bauss jacobbauss at gmail.com
Wed Mar 26 20:16:54 UTC 2025


On Wednesday, 26 March 2025 at 16:59:47 UTC, Steven Schveighoffer 
wrote:
> I think we should enable this. It was identified pretty 
> recently in a stream of an influencer (see other messages in 
> this group), as something that is desirable.
>
> Especially with importC, where C does not support operator 
> overloading, it should just work. Indeed, in my [raylib 
> binding](https://github.com/schveiguy/raylib-d/blob/1cc76b8be3da3c1a34c54528678a62ce237c969e/source/raylib/raylib_types.d#L7), we purposely implement our own copies of all the basic POD types because we want to add operator overloads. This becomes MUCH simpler if we could just use UFCS operators.
>
> A long time ago, member functions were member functions only, 
> and UFCS did not exist (except for arrays). Now that UFCS does 
> exist, and operator overloads are a straightforward template 
> rewrite, the position of only allowing operator overloads to be 
> members is less defendable.
>
> I also agree with the streamer that .h files should just work.
>
> -Steve

+1


More information about the Digitalmars-d mailing list