r/ProgrammerHumor • • 17d ago

Meme cppAndItsVectorBooleans

Post image
3.4k Upvotes

214 comments sorted by

View all comments

Show parent comment

7

u/Thrawn89 17d ago

Maybe optimize the memory footprint, but if it packs them, then the underlying memory hardware wont be able to just write to them directly.

All of a sudden you double your access bandwidth on writes since they may be promoted to read-modify-writes.

3

u/0xbenedikt 17d ago

It depends a lot on what platform the software runs on. C++ runs on everything from 8-bit microcontrollers to high performance compute platforms. On a microcontroller there often is an instruction that modifies a bit in a single cycle, while it is more costly on other platforms