On 27 September 2015 at 17:20, Matt Calabrese
On Sun, Sep 27, 2015 at 3:08No, in other words you cannot construct a card with a not-a-card state.
Except that every function in its implementation may assume the card is *never* in the not-a-card state. For instance, one could add ASSERT(1 <= cardIndex && cardIndex <= 52) all over the place, including in the beginning of the body of the destructor, and not expect anything to break.
Internally there is obviously room in storage to represent it, since we are only using 52 values on the possible set of values that can exist for a byte, but with just this abstraction there is no valid way to get there.
It isn't just about room. The class has to know about it so that it can, at a minimum, weaken its invariants to support it. And if you have to do that, I don't see any need for some generic class to wrap it. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404