vector<bool>::reference::flip

反转引用的 vector<bool> 元素的布尔值。

void flip();

示例

// vector_bool_ref_flip.cpp
// compile with: /EHsc /W4
#include <vector>
#include <iostream>

int main()
{
    using namespace std;
    cout << boolalpha;

    vector<bool> vb = { true, false, false, true, true };

    cout << "The vector is: " << endl << "    ";
    for (const auto& b : vb) {
        cout << b << " ";
    }
    cout << endl;

    vector<bool>::reference vbref = vb.front();
    vbref.flip();

    cout << "The vector with first element flipped is: " << endl << "    ";
    for (const auto& b : vb) {
        cout << b << " ";
    }
    cout << endl;
}

输出

The vector is:
    true false false true true
The vector with first element flipped is:
    false false false true true

要求

标头:<vector>

命名空间: std

请参见

参考

vector<bool>::reference 类

标准模板库