Boost logo

Boost :

Subject: Re: [boost] PR: Remove safe_bool idiom from boost.tribool
From: Robert Ramey (ramey_at_[hidden])
Date: 2018-05-21 14:53:55


On 5/20/18 5:34 PM, Gavin Lambert via Boost wrote:
> On 20/05/2018 06:34, Robert Ramey wrote:
>> As usual, discussions have gotten off on various tangents.
>>
>> My proposal is to replace the safe_bool idiom used in boost::tribool
>> with a simple operator bool.
>
> I'm strongly opposed to downgrading from safe_bool to implicit bool.

I made my argument why this is good idea. What's wrong with my argument?

>
> Upgrading to explicit bool is ok, but you can only do that on C++11;
> it's not safe in older compilers.

This would/could break lot's of current code. Basically any code which
looks like the following:

bool f() {
        tribool tb ...
        return tb;
}

which to me looks like a perfectly reasonable thing to do. But using
explicit would create a compile time error.
>
> I would be ok with #if logic that uses safe_bool on older compilers and
> explicit bool on C++11 and up.

This to me seems the worst. It would mean that the semantics of tribool
vary depending on which standard the compiler is adhering to. It would
be impossible to discern the behavior of the code just by looking at it.
You'd have to know which compile time switches are being used.

Robert Ramey


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