Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2002-08-02 12:24:16


From: "William E. Kempf" <williamkempf_at_[hidden]>
>
> From: "Rob Stewart" <stewart_at_[hidden]>
>
> > 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:

Indeed, that's what I was thinking. b isn't initialized to anything known, so
it's value is, effectively, unknown or indeterminate.

> bool b();
>
> initializes b to false. So I'd think the default ctor should initialize
> the state to false.

That doesn't invoke the default ctor. You'd have to do something like this:

   bool b(bool());

to get what you're referring to.

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

This in an interesting approach. I could see it being implemented with a char
-- or other parameterized integer type -- with distinct true and false values,
plus a range of other legal values in between. Based upon what you're saying,
the other values can then be named externally; the names needn't be part of the
class. That seems like it is workable without being unwieldy.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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