Nigel Rantor wrote:
Robert Ramey wrote: Pragmatic:
Well, how about simply treating anything other than 1 as false? I realise this means that you are implicitly initialising someone elses variable should they serialise and then deserialise but it would seem to preserve the effect that you would witness should you use such a variable without performing that set of operations anyway so it would be an "invisible" side-effect.
Correct:
Initialise all your variables. Shoot all programmers who don't!
And of course, the one true way - tell everyone to initialise their variables or bad things might happen and then be lenient on parsing anyway.
Actually, my preferred way would be to trap the usage of an unitialized bool variable when it is saved. Its not clear that I can do this. But a close substiture might be to convert the variable to an integer, throw an exception if its not equal to 0 or 1 and serialize it otherwise. Robert Ramey