Some time ago I went through the need to store 4 integrals ranging from 0-10 in the least possible space in memory. During the decision period of how I was going to store these values, I considered bitset<16> and vector<bool>(16) possibilities. But I convinced myself then these weren't good because my readings of the sizeof operator when applied on them gave me disheartening results. I ended up using unsigned char. It's working.
However just recently I go my hands on Herb Sutter's "Exceptional C++ Style" which discusses this very same issue and it says there both STL types have no memory overhead. So what gives?
On my system:
sizeof unsigned char = 2
sizeof bitset<16> = 4
sizeof vector<bool>(16) = 14
Why do I get these values then? What is sizeof reporting? Or... maybe the correct question is how do I know exactly how much a STL container occupies in memory?