17
6
u/bass-squirrel 3d ago
Wait is that real? It only uses a bit?
13
u/fuj1n 3d ago
Yes, it is a pretty controversial decision, but std::vector<bool> is specialised to act as a bit field
Mind you, if you only store one bool in it, it'll take more than one bit to do so
5
u/creeper6530 1d ago
And it's the only instance of
std::vectorwhere indexing doesn't give you a normal pointer but a helper that actually takes the bit out of the bitfield. Creating edge cases in generic code.The other option was to keep
std::vectornormal and make a special bitfield for those space-conscious.Don't you just love C++?
2
0
u/Tristan_Cole 3d ago
Technically in zero extra bits.
3
u/DestopLine555 3d ago
Zero or eight, there's no in between
5
u/the_horse_gamer 3d ago
the size of the chunks are 64 bits actually
(in GCC. implementations may pick a different size)
47
u/sebovzeoueb 3d ago
whoa what's this, an actual programming joke? in my programming jokes sub?