29.2. Default Construction
This one's a no-brainer. I usually go for maximum speed here and do not initialize the member(s) of the integer type, consistent with the behavior for the built-in types. There's very little in it, though, and you'd be perfectly reasonable to decide to zero initialize the members.
One interesting strategy is to maintain an extra member, perhaps in debug builds only, which denotes an uninitialized integer, in much the same way as does the special value NaN for floating point types. Access of the values from uninitialized (i.e., default initialized) instances would result in a precondition violation assertion.
|