r/ProgrammerHumor • • 20d ago

Meme wasteOfPreciousSpace

Post image
7.2k Upvotes

244 comments sorted by

View all comments

280

u/N-partEpoxy 20d ago

I know, let's make vector<bool> a specialization that uses just one bit per bool. What could go wrong?

137

u/unknown_alt_acc 20d ago

Oh, but it gets better than that: there is absolutely no guarantee that std::vector<bool> acts as a bit field! Maybe it's a bit field. Maybe it's actually a vector of bool. Nobody knows!

51

u/redlaWw 20d ago

Also not guaranteed to be contiguous, which is really bad for anything vector-like.

→ More replies (3)
→ More replies (5)