On Wed, 2 May 2018, Derek Gaston wrote:

I'll add one more reason to hate std::vector<bool>: threading.

Yikes, I forgot that!  Glad I added you all to the Cc; thanks!

std::vector<bool> is not at _all_ thread safe: multiple processors working on 
the
same vector will clobber each other's values.

Assuming by "working on" you mean "writing to", then yeah:

"Notwithstanding (17.6.5.9), implementations are required to avoid
data races when the contents of the contained object in different
elements in the same container, excepting vector<bool>, are modified
concurrently."

You're supposed to still be able to read in multiple threads
concurrently just fine, though.

I personally wish they had made std::vector<bool> take 8 times more
memory... and then let you use something else if you needed the
optimization... but that's just me.

You, and Hinnant... and honestly I agree too, just not quite as
strongly.  I'm deeply opposed to the "resizeable bitsets shouldn't
exist" attitude I see sometimes, but "resizeable bitsets shouldn't
have been named std::vector" is pretty hard to argue with.
---
Roy

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to