1163
Tell me the truth ... (piefed.jeena.net)
you are viewing a single comment's thread
view the rest of the comments
[-] savedbythezsh@sh.itjust.works 14 points 3 weeks ago

Are you telling me that no compiler optimizes this? Why?

[-] timhh@programming.dev 24 points 3 weeks ago

Well there are containers that store booleans in single bits (e.g. std::vector<bool> - which was famously a big mistake).

But in the general case you don't want that because it would be slower.

[-] ethancedwards8@programming.dev 7 points 3 weeks ago

Why is this a big mistake? I’m not a c++ person

[-] bitcrafter@programming.dev 5 points 3 weeks ago

The mistake was that they created a type that behaves like an array in every case except for bool, for which they created a special magical version that behaves just subtly different enough that it can break things in confusing ways.

[-] ethancedwards8@programming.dev 2 points 3 weeks ago

Could you provide an example?

[-] timhh@programming.dev 1 points 2 weeks ago

The biggest problem is that each element doesn't have a unique memory address; iterators aren't just pointers.

load more comments (8 replies)
this post was submitted on 15 May 2025
1163 points (98.6% liked)

Programmer Humor

23899 readers
1943 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