Convert between std :: bitset and std :: vector <bool>
I have it std::bitset, but now I want to use the STL algorithm on it.
I could use std::vector<bool>instead, but I like the constructor std::bitset, and I want bitwise operations std::bitset.
Do I have to go through a loop and everything in std::vector<bool>using STL algorithms and then copy it back to std::bitset, or is there a better way?
+4
2 answers
Matthew Austern wrote an iterator for bitsethere: http://www.drdobbs.com/the-standard-librarian-bitsets-and-bit-v/184401382?pgno=2
100 , , , , . STL.
:
STL, - () . , , " ", * , b [n]. : .
:
, , . pre-STL, STL, .
, vector<bool>::iterator, Austern bitset_iterator::operator* bool&, : bitset<>::reference.
bitset_iterator :
std::bitset<10> foo;
std::vector<bool> bar(begin(foo), end(foo));
0