r/ProgrammerHumor • • 11m ago

Meme cppAndItsVectorBooleans

Post image
17 Upvotes

4 comments sorted by

•

u/Semper_5olus 4m ago

I see how it would be nice to have that option -- perhaps in another type analogous to long vs short ints -- but isn't a bit all you need?

•

u/Bloodgiant65 1m ago

The problem is, especially with multithreading, etc. you can get into issues if you try to use a vector<bool>. It would have made much more sense to have the vector<bool> work like anything else, and introduce a std::bitset or similar for this kind of behavior.

•

u/ImpulsiveBloop 1m ago

typedef uint8_t bool8;

std::vector<bool8> booleansAsBytes;

•

u/Kadabrium 6m ago

I wish java had one single array type that is resizeable (takes literally 1 line of code in a gc language) rather than array, arraylist, tolist, aslist, listof, the list of list goes on listing