@cm0002@lemmy.world to Programmer Humor@programming.dev • 2 days agoTell me the truth ...piefed.jeena.netimagemessage-square122fedilinkarrow-up11.08K
arrow-up11.08KimageTell me the truth ...piefed.jeena.net@cm0002@lemmy.world to Programmer Humor@programming.dev • 2 days agomessage-square122fedilink
minus-square@timhh@programming.devlinkfedilink24•19 hours agoWell 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.
minus-square@ethancedwards8@programming.devlinkfedilinkEnglish6•11 hours agoWhy is this a big mistake? I’m not a c++ person
minus-square@bitcrafter@programming.devlinkfedilink4•10 hours agoThe 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.
minus-square@ethancedwards8@programming.devlinkfedilinkEnglish2•9 hours agoCould you provide an example?
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.
Why is this a big mistake? I’m not a c++ person
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.Could you provide an example?