vector<bool>::flip
Reverses all bits in a vector<bool>.
void flip();
Example
// vector_bool_flip.cpp
// compile with: /EHsc /W4
#include <vector>
#include <iostream>
int main()
{
using namespace std;
vector<bool> vb = { true, false, false, true, true };
cout << "The vector is: ";
for (const auto& it : vb) {
cout << it << " ";
}
cout << endl;
vb.flip();
cout << "The flipped vector is: ";
for (const auto& it : vb) {
cout << it << " ";
}
cout << endl;
}
Output
The vector is: 1 0 0 1 1
The flipped vector is: 0 1 1 0 0
Requirements
Header: <vector>
Namespace: std