Compartir a través de


vector<bool>::reference::operator~

Devuelve un valor booleano que es el contrario de que mantenidas por el elemento hace referencia.

bool operator~( ) const;

Valor devuelto

El valor booleano invertido de elementos de vector.

Comentarios

El objeto vector no se puede modificar por este operador.

elemento también invierte el valor booleano de un elemento de vector.

Ejemplo

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

int main( ) 
{
   using namespace std;
   typedef vector<bool> boolvector;
   boolvector v;
   bool b1 , b2; 

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

   // There are two ways to invert the value:
   b1 = ref1.operator~( );
   b2 = ~ref2; 

   cout << "Value of inverted 1st element obtained is: " << b1 << endl;
   cout << "Value of 1st element in vector is still: " << ref1 << endl;
   cout << endl;
   cout << "Value of inverted 2nd element obtained is: " << b2 << endl;
   cout << "Value of 2nd element in vector is still: " << ref2 << endl;
   cout << endl;
}
  

Requisitos

encabezado: <vector>

espacio de nombres: std

Vea también

Referencia

vector<bool>::reference Class

Biblioteca de plantillas estándar