As stated in the subject: does vector<atomic_bool>
involves coalescing vector elements in the same way of vector<bool>
?
Asked
Active
Viewed 104 times
3

grd
- 287
- 1
- 2
- 8
1 Answers
4
No. std::vector has only one specialization, std::vector<bool>
. bool
and std::atmoic_bool
are two different types and as a result std::vector<atomic_bool>
will work like other std::vector<T>
of type T
.

taskinoor
- 45,586
- 12
- 116
- 142
-
Actually, the underlying question was this: how could I implement a thread-safe bitvector? To get an idea, I would like a kind of ```vector
```such that multiple threads can access the _i_-th element (bit) without data races. – grd Jul 19 '19 at 12:53 -
1@grd -- ask that as a question! The answer is to write a loop with `std::compare_exchange_strong`. – Pete Becker Jul 19 '19 at 13:06