vector<bool>::reference::operator~
Restituisce un valore booleano che rappresenta l'opposto di quello utilizzato dall'elemento fa riferimento.
bool operator~( ) const;
Valore restituito
Il valore boolean invertito dell'elemento vettoriali.
Note
L'oggetto vettoriale non può essere modificato da questo operatore.
capovolgere anche inverte il valore booleano di un elemento vettoriali.
Esempio
// 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;
}
Requisiti
intestazione: <vector>
Spazio dei nomi: deviazione standard