r/ProgrammerHumor • • 20d ago

Meme cppAndItsVectorBooleans

Post image
3.4k Upvotes

214 comments sorted by

View all comments

Show parent comment

1

u/dedservice 14d ago

Using uint_8 isn't bad, but rather it's not an option as a replacement if you're the one writing the templated code. Partually because you don't know that bool was actually the intent when you get given a uint_8, but more importantly because in every single function that templates on T and uses vector<T>, you have to write a distinct version of the function that special-cases vector<bool> in case your users instantiate the template with a bool, which should be very reasonable and users should want to do by default, because bools are a useful datatype.

1

u/ImpulsiveBloop 14d ago

Hence why I said, "larger programs can afford mor refined solutions"... :/

I only mean that uint8_t is not bad for smaller programs because it does what it needs and is unlikely to cause any complications.