this post was submitted on 15 May 2025
1158 points (98.6% liked)

Programmer Humor

23376 readers
1120 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] pelya@lemmy.world 33 points 6 days ago (2 children)

std::vector<bool> fits eight booleans into one byte.

[–] TimeSquirrel@kbin.melroy.org 8 points 6 days ago

std::vector<std::vector> is how I stored the representation of a play field for a Tetris game I made once.

[–] borokov@lemmy.world 2 points 5 days ago
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.