|
Boost : |
From: g.peterhoff_at_[hidden]
Date: 2024-05-04 16:44:30
> Since you are asking this question on a Boost distribution list, I assume that you would like to get a Boost-like review of your library. One criterion for a Boost-quality library that I can offer is the quality of the documentation. A good documentation should:
> * Briefly (in five minutes or less) convince the reader that it is worth investing time in studying the library,
> * Describe what computational problems it helps solving,
> * Convince that it will be a good fit in users' programs,
> * Demonstrate the usage,
> * Provide enough information that I know how to use it in my programs.
> For now, having browsed the repo and read this thread, I do not know what I would need this library for. The only information that I got is that `bool3` is an "improved" version of Boost.Tribool. I do not know why anyone would use `bool2` or `bool4`. As a potential user I would like to know that. Could you show us some small programs, where using `bool4` actually helps? Similarly, can you show us the program example where using a weak negation makes the program cleaner or more efficient or less bug-prone?
> I think this is the necessary step to enable more useful feedback and criticism.
Hello Andrzej,
thank you for your comments. Here is a short answer.
As I said, this library (like all boost libraries) is for general purposes. You could also ask why there is e.g. boost::math::quaternion/octonion. I don't know of a specific purpose for this either, but it makes sense to have them generally available. tribool is used in some booost libraries, which proves the usefulness of bool3. You can also provide bool4/2, since the implementation is quite simple.
I think that a boost class
- should be as complete as possible in terms of its operations/operators
- should provide as many (if possible/useful) std operations as possible
Unfortunately tribool does not do that.
small documentation
Because of the strange implementation of tribool::indeterminate, the classes are *not* compatible with tribool, as they should be in the same namespace. This is checked (static_assert). Compatibility could be achieved by:
- bool4/3/2 in its own namespace (e.g. logic2) -> but I don't think that makes sense
- typedef bool3 tribool; not checked
implement bool4/3/2
- operator&& ooperator||
- operator!
- operator~ weak negation; for bool2 this is identical to operator!
- conversion constructors, where constructor(something) is deleted to prevent misuse
- conversion operators for bool and unsigned
- operator<< operator>> for streams, whereby boolalpha is taken into account; however, false is always returned for operator>> in the event of an error
- to_(w)string like to_(w)string(bool) -> numeric result
- numeric_limits
- if available from/to_chars and/or boost::from/to_chars
- if available formatter (but is still very simple)
- the values are encapsulated and cannot be manipulated directly
There is really nothing more to say.
I have implemented the logical operators for bool4/3 using a table and for bool2 using bit operations. As already written, the tables should be checked again for correctness.
https://github.com/boostorg/logic/issues/30
regards
Gero

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