"Robert Ramey"
Paul Giaccone wrote:
For booleans, though, a value of other than 0 or 1 means it has not been initialised, and perhaps this should throw an exception on writing to the archive rather than on reading from it.
Hmmm, I'm not sure about this. Do we know for a fact that a bool variable will always contain 1 or 0?
Technically, no. We know that an initialized bool will always contain either true or false. 3.9.1 6 Values of type bool are either true or false. true can be converted to 1 and false can be converted to 0. See 4.5 and 4.7.
I've never seen code trap on an un-initialized bool. It seems that even an uninitialized bool corresponds to true or false.
No, an uninitialized bool can't be read without inducing undefined behavior, same as any other uninitialized data. It has no value that can be legally detected. -- Dave Abrahams Boost Consulting www.boost-consulting.com