vector<bool>::flip
會反轉 vector<bool> 中的所有位元。
void flip();
範例
// vector_bool_flip.cpp
// compile with: /EHsc /W4
#include <vector>
#include <iostream>
int main()
{
using namespace std;
cout << boolalpha; // format output for subsequent code
vector<bool> vb = { true, false, false, true, true };
cout << "The vector is:" << endl << " ";
for (const auto& b : vb) {
cout << b << " ";
}
cout << endl;
vb.flip();
cout << "The flipped vector is:" << endl << " ";
for (const auto& b : vb) {
cout << b << " ";
}
cout << endl;
}
Output
The vector is:
true false false true true
The flipped vector is:
false true true false false
需求
標頭:<vector>
命名空間: std