r/ProgrammerHumor • • 15d ago

Meme cppAndItsVectorBooleans

Post image
3.4k Upvotes

214 comments sorted by

View all comments

Show parent comment

1

u/zhaDeth 8d ago

Does that mean it constantly changes from "bit" bools to normal byte bools each time you use it?

1

u/Drugbird 8d ago

Yes. You can't have a normal bool pointer or reference into the vector, because there aren't any "regular" byte sized bools in there.

So any time you read a bool, it needs to create a new byte bool for the result. And when you write a bool, it needs to convert that bool to the correct bit flipping operation in the vector.

Particularly when you read a bool it's problematic because you can't e.g. take the address of it and expect to get an address inside the vector (which you can do with any other type of vector).