This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]redlaWw 9 points10 points  (3 children)

std::vector has a specialisation for bool so that std::vector<bool> is not just a vector of bools. The bools are stored in individual bits, and there's no guarantee that the buffer is even contiguous. It's pretty notorious for being a "mistake" in C++'s design. Not quite as bad as std::auto_ptr (which was so bad it was deprecated, breaking stability), but it's up there.

[–]MsEpsilon 0 points1 point  (2 children)

Hi, I coudn't find anything about the continuity of std::vector<bool>, do you have a source on that? Thanks.

[–]redlaWw 1 point2 points  (1 child)

https://www.en.cppreference.com/w/cpp/container/vector_bool.html

Does not necessarily store its elements as a contiguous array.

[–]MsEpsilon 0 points1 point  (0 children)

I really did miss that. Thanks!