Udostępnij za pośrednictwem


vector<bool>::reference::flip

Odwraca wartość logiczną odnośnego elementu vector<bool>.

void flip();

Przykład

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

Dane wyjściowe

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

Wymagania

Nagłówek: <vector>

Przestrzeń nazw: std

Zobacz też

Informacje

vector<bool>::reference — Klasa

Standardowa biblioteka szablonów