Operator overloading or alternatives to expression templates
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 14 11:45:02 PDT 2015
On Monday, 14 September 2015 at 18:24:00 UTC, Andrei Alexandrescu
wrote:
> On 09/14/2015 07:32 AM, burjui wrote:
>> On Sunday, 13 September 2015 at 17:16:40 UTC, Daniel N wrote:
>>> int opCmp(Foo rhs)
>>> {
>>> return (id > rhs.id) - (id < rhs.id);
>>> }
>>
>> IMO, subtracting boolean values is bad code style
>
> I love it! -- Andrei
Beside loving, it, this has good ILP, no branches, and have nice
codegen on most CPUs.
I was surprised to find that style in jemalloc, and compared to
various alternatives. The only way I was able to get better is by
ignoring (and by extension getting invalid results) overflow.
More information about the Digitalmars-d
mailing list