Boost logo

Boost :

From: William E. Kempf (williamkempf_at_[hidden])
Date: 2002-08-02 10:05:21

----- Original Message -----
From: "Rob Stewart" <stewart_at_[hidden]>
To: <boost_at_[hidden]>
Cc: <boost_at_[hidden]>
Sent: Friday, August 02, 2002 9:15 AM
Subject: Re: [boost] 3-state boolean type

> It seems to me that the default ctor should initialize the state to
> indeterminate (or whatever it will be called). Since bool doesn't have a
> default ctor, this is the most logical behavior for tribool.

That depends on what you mean here.

bool b;

This doesn't initialize the value for b, and thus would (fuzzily) suggest
what you're saying. However, this:

bool b();

initializes b to false. So I'd think the default ctor should initialize
the state to false.

> I agree with the sentiments regarding the name. Of those suggested thus
far, I
> like tristate.

I'd call it logic_state. A value of 0 would indicate false, a value of 1
would indicate true, and any other value would be "indeterminate", giving
you the multiple "indeterminate" states people have suggested. Of course
you could templatize this so that logic_state could specify the number of
indeterminate states. As for symbolic names... I wouldn't specify any, and
let the user specify the ones that fit his domain. Alternatively, you could
specify one or more well known sets of symbolic names, such as the suggested

> I don't think such a simple type should be overly complicated with support
> various numbers of states unless it can be managed by a template and
> approach. If a tristate version of such a template uses
> while a quadstate version uses {true,false,maybe_true,maybe_false},
etc. -- that
> is, each variation can have its own names for the values such that they
> sensible for the number of states -- then it will be sensible. Without
> characteristics, it will be too unwieldy.

I would think you could do this through template mechanisms.

> I can't think of a use for n-state logic at the moment in my current
> but several of the suggested uses did resonate with me. For example, I
> done GUI programming in the past and a tristate variable would work very
> to represent the tristate checkboxes in many GUIs. I can imagine that I
> have need for a tristate class in the future, so it would be nice to have
> available. Unfortunately, I can't say that it is a current or recent

I can second this sentiment.

Bill Kempf

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