Tristate - wanna?

Lionello Lunesu lionello at lunesu.remove.com
Wed Oct 30 08:43:09 PDT 2013


On 10/27/13, 11:07, Timon Gehr wrote:
> On 10/27/2013 02:11 AM, Andrei Alexandrescu wrote:
>> On 10/26/13 5:13 PM, Timon Gehr wrote:
>>> The following implementation does not use conditionals; probably
>>> not minimal.
>>
>> Thanks! Fixed two minor bugs:
>>
>>> this(bool b) { value = b; }
>>>
>>> void opAssign(bool b) { value = b; }
>>
>> These should shift b so it becomes 2 if true. ...
>
> Good point.
>
>> Pushed your code with the fixes and a full truth table unittest:
>>
>> https://github.com/andralex/phobos/blob/allocator/std/allocator.d#L236
>>
>>
>>
Nice work. I'd say this is nontrivial enough to be put in the standard
>> library.
>>
>>
>> Andrei
>>
>>
>
> Thanks!

Couldn't this be optimized further, by doubling the constants?

(A>>(a+b)&3)<<1 ==> A2>>(a+b)&6 ?


More information about the Digitalmars-d mailing list