Condividi tramite


vector<bool>::flip

Reverses all bits in a vector with Boolean elements.

void flip( );

Example

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

int main( )
{
   using namespace std; 
   _Bvector vb;

   vb.push_back( 0 );
   vb.push_back( 1 );

   cout << "The vector is: " << vb.front( ) << " " << vb.back( ) << endl;
   vb.flip( );
   cout << "The flipped vector is: " << vb.front( ) << " " << vb.back( ) << endl;
}

The vector is: 0 1
The flipped vector is: 1 0

Requirements

Header: <vector>

Namespace: std

See Also

Concepts

vector Class

vector<bool> Members

Standard Template Library