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

Programmer Humor

23417 readers
1699 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
[–] [email protected] 33 points 1 week ago (2 children)

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

[–] [email protected] 2 points 6 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.

[–] [email protected] 8 points 1 week ago

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