Freigeben über


vector<bool>::flip

Kehrt alle Bits in vector<bool> um.

void flip();

Beispiel

// 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;
}

Ausgabe

The vector is:
    true false false true true
The flipped vector is:
    false true true false false

Anforderungen

Header: <vector>

Namespace: std

Siehe auch

Referenz

vector-Klasse

Standardvorlagenbibliothek