For digital electronic circuit simulation, i wanted to implement Three states. i.e High, Low and Undefined in C++.
Boost::tribool, and they implement it using
Now for conserving some memory i have implemented it using 1 Byte Int
#ifdef _WINDOWS typedef __int8 State; #elif typedef int8_t State; #endif const State kLow = 0; const State kHigh = 1; const State kUndefined = 2;
- Do you see any potential problem with it?
- And why would one waste 4 bytes instead of a single byte for 3 values only
- Do you have a still better way?