On 27 June 2018 at 02:37, Gavin Lambert via Boost
On 27/06/2018 01:41, degski wrote:
Once one has adopted the idea of "flags" to possibly not exist, i.e. not to be either true or false, a natural extension is to adopt "fuzzy flags" as well, i.e. use floats. Some bike-shedding: I think the word flags is not sufficiently general.
At this point you've sufficiently departed the "bitwise operations" model to make it fairly meaningless.
You would implement trits with bitwise operations using BCT (Binary Coded Ternary: implementation http://homepage.divms.uiowa.edu/~jones/ternary/libtern.shtml). Ternaries have some interesting mathematical properties as well, which is explained here https://en.wikipedia.org/wiki/Redundant_binary_representation. There are also pratical applications https://en.wikipedia.org/w/index.php?title=Ternary_numeral_system&action=edit§ion=4. You'd probably be better served with a regular structure or with
Boost.ProgramOptions instead.
Did you read the G.O.A.P. link I posted (here's one from MIT http://alumni.media.mit.edu/%7Ejorkin/goap.html)? Because if you had, you would not suggest to solve this problem with Boost.ProgramOptions. As to the fuzzy idea, bits are not necessarily digital, think analog computers. Personally, I think the flags proposal is an instance of over-engineering and is making things that are fairly simple (and why not use bitfields, the compiler does the work, certainly better than any had-coded solution) complicated. It is also a well-known and understood idea. degski