@cm0002@lemmy.world to Programmer Humor@programming.dev • 1 month agoTell me the truth ...piefed.jeena.netimagemessage-square169arrow-up11.18K
arrow-up11.18KimageTell me the truth ...piefed.jeena.net@cm0002@lemmy.world to Programmer Humor@programming.dev • 1 month agomessage-square169
minus-squareTimeSquirrellinkfedilink8•1 month agostd::vector<std::vector<bool>> is how I stored the representation of a play field for a Tetris game I made once.
minus-square@borokov@lemmy.worldlinkfedilink2•1 month 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.
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.