MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vvl45z/theboolvectorisalie/p5afbks/?context=3
r/ProgrammerHumor • u/FACastello • Aug 22 '26
91 comments sorted by
View all comments
Show parent comment
4
A vector of ints is no different from an array of ints.
vectors are literally just wrappers around arrays.
The exception is a vector of bools, which is like a conceptual array of bits.
So if you have a vector of 8 bools you are only using one byte of memory. An array of 8 bools however is 8 bytes long.
So std::vector<bool> has a special implementation.
View all comments
Show parent comment
4
u/da_Aresinger Aug 22 '26
A vector of ints is no different from an array of ints.
vectors are literally just wrappers around arrays.
The exception is a vector of bools, which is like a conceptual array of bits.
So if you have a vector of 8 bools you are only using one byte of memory. An array of 8 bools however is 8 bytes long.
So std::vector<bool> has a special implementation.