Bitwise logic operations are supposed to be the fastest operations a CPU can run, though. Ideally you want to group up bits you're likely to read together into the same word so a single instruction reads all of them. Same goes for setting bits using a bitmask. You can still pointer iterate, but you're doing it per-word rather than per-bool. You'd get a speedup equal to the word size because you're effectively parallelizing your writes with a single bitwise logic instruction.
I personally tend to use C more than C++, and HDLs even more than that, but my first impression of bool was that it was meant to be a single bit in size so you could do things like that.
This seems like a special case that would benefit from its own type like bitset rather than having vectors arbitrarily work differently for a single type and break stuff unless you know to take care of it.
View all comments
Show parent comment
1
u/TatharNuar 17d ago
Bitwise logic operations are supposed to be the fastest operations a CPU can run, though. Ideally you want to group up bits you're likely to read together into the same word so a single instruction reads all of them. Same goes for setting bits using a bitmask. You can still pointer iterate, but you're doing it per-word rather than per-bool. You'd get a speedup equal to the word size because you're effectively parallelizing your writes with a single bitwise logic instruction.
I personally tend to use C more than C++, and HDLs even more than that, but my first impression of bool was that it was meant to be a single bit in size so you could do things like that.