r/ProgrammerHumor • • 10d ago

Meme cppAndItsVectorBooleans

Post image
3.4k Upvotes

214 comments sorted by

View all comments

60

u/tickle-fickle 10d ago

That pisses me off so much, why not call it an std::bit_vector, why a different behavior for this one template type

25

u/AL_O0 10d ago

funnily enough there absolutely is already std::bitset

and I have absolutely no idea how it's different

18

u/tiajuanat 10d ago

Bitset is fixed size. Vector<bool> is dynamic, does not allow concurrent access and does not guarantee continuity of values in memory.

Vector<bool> was meant to be an example template specialization, which is why it's so funky.

1

u/AL_O0 10d ago

thank you, that does make more sense

5

u/gigayoink 10d ago

I see how slick and natural it would have been, but it just doesn't work out that way in practice