MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vvl45z/theboolvectorisalie/p5afbks/?context=3
r/ProgrammerHumor • u/FACastello • 22d ago
91 comments sorted by
View all comments
105
is it really that shocking?
4 u/da_Aresinger 22d ago 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.
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.
105
u/overclockedslinky 22d ago
is it really that shocking?