Partager via


vector<bool>::reference::flip

Inverts the Boolean value of a vector element.

void flip( );

Remarks

reference operator~ also inverts the Boolean value of a vector element.

Example

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

class MyAlloc{};
int main( ) 
{
   using namespace std;
   typedef vector<bool> boolvector;
   boolvector v;

   v.push_back( false );
   boolvector::reference ref1 = v.at( 0 );

   cout << "The original value of the 1st element is: " << bool( ref1 ) << endl;
   ref1.flip( );
   cout << "The value of the 1st element is now: " << ref1 << endl;
}

The original value of the 1st element is: 0
The value of the 1st element is now: 1

Requirements

Header: <vector>

Namespace: std

See Also

Concepts

vector<bool>::reference Class

vector<bool>::reference Members

Standard Template Library