cm0002@lemmy.world to Programmer Humor@programming.dev · 10 days agoTell me the truth ...piefed.jeena.netimagemessage-square158linkfedilinkarrow-up1411arrow-down16
arrow-up1405arrow-down1imageTell me the truth ...piefed.jeena.netcm0002@lemmy.world to Programmer Humor@programming.dev · 10 days agomessage-square158linkfedilink
minus-squarepelya@lemmy.worldlinkfedilinkarrow-up2·10 days agostd::vector<bool> fits eight booleans into one byte.
minus-squareborokov@lemmy.worldlinkfedilinkarrow-up2·8 days agoauto 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.
minus-squareTimeSquirrel@kbin.melroy.orglinkfedilinkarrow-up2·10 days agostd::vector<std::vector<bool>> is how I stored the representation of a play field for a Tetris game I made once.
std::vector<bool>
fits eight booleans into one byte.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<std::vector<bool>> is how I stored the representation of a play field for a Tetris game I made once.