Boost logo

Boost :

Subject: Re: [boost] [variant] Maintainer
From: Robert Ramey (ramey_at_[hidden])
Date: 2015-06-28 13:40:35


On 6/28/15 9:41 AM, Niall Douglas wrote:
> On 28 Jun 2015 at 9:30, Robert Ramey wrote:
>
>> On 6/28/15 6:15 AM, Niall Douglas wrote:
>>> https://github.com/ned14/boost.spinlock/blob/master/include/boost/spin
>>> lock/tribool.hpp
>>
>> How is this better/different than the current boost::tribool?
>
> 1. Mine is 100% constexpr.

Looks to me that boost::tribool is also.

> 2. I think mine implements std::min/max and other ternary logic
> primitives Boost.Tribool does not. I didn't look into it in detail.

Hmmm - I don't see min/max in here.

I do see in here a number of things I would not expect to see:

operator~, operator| and operator&

the enum shows 5 states - three of which have the same value. Very odd
to me.

> 3. Mine is much more conservatively designed. Specifically:
>
> a. No automatic conversion operators, thus preventing
> assert(something==!!something). It also forces the programmer to
> explicitly state what they mean when working with tribools, see
> below.

> b. operator&& and operator|| return bool, not tribool. If you want
> tribool outcomes, use the bitwise operators.

These are design choices which one might or might not agree with. They
don't resonate for me.

> I'm also matching 100%
> the C++ standard text on this where logical operators are supposed to
> return only bool.

I don't see this. If you're referring 5.14,... I think those paragraphs
referring to the builtin- not overloaded versions. On the other hand,
some other part might refer to overloaded operations. I didn't see it
and it would surprise me to find it.

>> I've used this on several occasions with good success. It's well
>> documented as well.
>
> I was being incredibly paranoid with my tribool. Almost certainly
> excessively so. But they're new to me, so I was being extra cautious
> to make sure I didn't shoot myself in the foot later. Besides,
> writing this by hand:
>
> tribool t;
> if(true_(t)) ...
> else if(false_(t)) ...
> else if(unknown_(t)) ...

Arrrrgggghhh.

> ... isn't too bad, and has the advantage of being very clear even to
> programmers not familiar with tribool (i.e. me).
>
> Niall

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk