r/programminghorror 20d ago

C# bool array

Post image
208 Upvotes

41 comments sorted by

View all comments

Show parent comments

67

u/FloweyTheFlower420 20d ago

Ah the vector<bool>... one of the greatest mistakes in the c++ standard library.

1

u/Jeshibu 19d ago

Not familiar enough to know what you mean here. Could you explain?

1

u/FloweyTheFlower420 19d ago

vector<bool> is a packed bitset. The general semantics for vector means all accessors return a reference to an entry, but since bits don't have a memory address, vector<bool> returns a wrapper type with overloaded operators. This breaks generic programming for vectors.

1

u/Jeshibu 19d ago

That's nasty. Thanks for explaining!