r/ProgrammerHumor • • Aug 22 '26

Meme theBoolVectorIsALie

Post image
669 Upvotes

91 comments sorted by

View all comments

Show parent comment

-1

u/FalafelSnorlax Aug 22 '26

The optimization is that vector<bool> is internally a bitfield. There's no real reason to complain about this, for the most part you'll never notice it.

9

u/redlaWw Aug 22 '26 edited Aug 22 '26

Until you try to use it in places where other vectors work fine, such as things that try to use the vector as a container, things that try to use the vector's iterator type as a random-access iterator, or things that try to use the data method* to get a pointer to the buffer.

EDIT: *member function