Boost logo

Boost :

Subject: Re: [boost] [variant] Maintainer
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-06-28 14:10:55


On 28 Jun 2015 at 10:40, Robert Ramey wrote:

> >> How is this better/different than the current boost::tribool?
> >
> > 1. Mine is 100% constexpr.
>
> Looks to me that boost::tribool is also.

Yes, you're right. The source code was updated without making the
change obvious in the docs.
 
> > 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&

Kleene logic provides all those tribitwise operations.

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

The indeterminate state in ternary logic has overloaded meaning.
Sometimes by indeterminate you mean unknown, other times you mean a
known state other than true or false.

I too am not a fan of aliasing naming. I had been thinking of some
method to enforce naming consistency, such that unknown state is a
different type to other state and to indeterminate state. That way
you're forced to use consistent naming. But that's a todo.

Unfortunately enums aren't permitted to use an underlying type which
is not an integral type, otherwise the tribool's states could
themselves be enum types.

> > 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 was worried that a container of tribool might not behave as
expected. As I mentioned, I was being paranoid.

> >> 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.

I'm more than happy to reform my tribool into something better. In
particular if you can suggest a better method equally as clear to
non-Boost programmers I am very interested. Most programmers have no
conceptualisation of a logic beyond boolean, and that's my number one
criticism of Boost.Tribool's "appear as if I am a bool" programming
style.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ 
http://ie.linkedin.com/in/nialldouglas/



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