Am I evil for this?

jmh530 john.michael.hall at gmail.com
Sat Oct 15 14:22:46 UTC 2022


On Friday, 14 October 2022 at 21:49:31 UTC, Dennis wrote:
> On Friday, 14 October 2022 at 20:24:47 UTC, jmh530 wrote:
>> [...]
>
> You can actually do that in D with some hacks:
>
> ```D
> struct Operator(alias fn, string operator = "/")
> {
>     static auto opBinaryRight(string op : operator, T...)(T 
> value1)
>     {
>         struct Result
>         {
>             auto opBinary(string op : operator, U...)(U value2)
>                 if (__traits(compiles, fn(value1, value2)))
>             {
>                 return fn(value1, value2);
>             }
>         }
>
> [...]

That's a new one to me. Very interesting.


More information about the Digitalmars-d mailing list