Boost logo

Boost :

Subject: Re: [boost] PR: Remove safe_bool idiom from boost.tribool
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-05-20 01:58:11

On Sun, May 20, 2018 at 2:54 AM, Edward Diener via Boost
<boost_at_[hidden]> wrote:
> On 5/19/2018 1:22 PM, Andrey Semashev via Boost wrote:
>> I tried using tribool in my projects multiple times and every time I
>> dropped it soon after the start in favor of an enum or something
>> similar. The reason is that I can never readily tell how the
>> conversion to bool works. The example above illustrates this rather
>> well - I can never say what foo will receive if t is indeterminate.
> It is documented that the:
> "conversion to bool will be true when the value of the tribool is always
> true, and false otherwise."
> So you always know how the conversion to bool works. Not reading the doc is
> not an excuse for not knowing.

Some stuff is intuitive and you don't even need to read the docs to
know how it works. Some other stuff is arbitrary and I will never
remember how it works no matter how many times I read the docs. This
tribool conversion to bool is of the latter kind. And frankly, without
having looked at the docs I would have guessed that it converts to
false if the tribool is false and true otherwise because that's how
other types work (e.g. pointers convert to false when null and true
when any other value).

Boost list run by bdawes at, gregod at, cpdaniel at, john at