As far as I know:
vector<bool>involves coalescing vector elements, that is: V[i] occupies a single bit, instead ofsizeof(bool)bytes."Coalesced"
vector<bool>is not "bit"-thread-safe, meaning that concurrent writes, even to different positions, do not guarantee the absence of data races (a nice discussion around the standardized "vector"vector<bool>is to be found here).It would be great, but no:
vector<std::atomic_bool>does not involve low-level coalescing.Even using
std::bitsetis not bit-thread-safe (here).
Given all of that, here is my question: how would you implement a coalesced vector<bool> such that concurrent writes to different position/bits are thread-safe?