cm0002@lemmy.world to Programmer Humor@programming.dev · 1 年前Tell me the truth ...piefed.jeena.netimagemessage-square167linkfedilinkarrow-up1986arrow-down115cross-posted to: programmerhumor@lemmy.ml
arrow-up1971arrow-down1imageTell me the truth ...piefed.jeena.netcm0002@lemmy.world to Programmer Humor@programming.dev · 1 年前message-square167linkfedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squarepelya@lemmy.worldlinkfedilinkarrow-up31·1 年前std::vector<bool> fits eight booleans into one byte.
minus-squareTimeSquirrel@kbin.melroy.orglinkfedilinkarrow-up8·1 年前std::vector<std::vector<bool>> is how I stored the representation of a play field for a Tetris game I made once.
minus-squareborokov@lemmy.worldlinkfedilinkarrow-up2·1 年前auto v = std::vector<bool>(8); bool* vPtr = v.data; vPtr[2] = true; // KABOOM !!! I’ve spent days tracking this bug… That’s how I learned about bool specialisation of std::vector.
std::vector<bool>fits eight booleans into one byte.std::vector<std::vector<bool>> is how I stored the representation of a play field for a Tetris game I made once.
auto v = std::vector<bool>(8); bool* vPtr = v.data; vPtr[2] = true; // KABOOM !!!I’ve spent days tracking this bug… That’s how I learned about bool specialisation of std::vector.