vector<bool>::reference::operator~
Zwraca wartość logiczną, która jest przeciwieństwem tego elementu, do którego odwołuje się w posiadaniu.
bool operator~( ) const;
Wartość zwracana
Wartość logiczna odwrócony elementu vector.
Uwagi
Nie można modyfikować obiektów wektorowych przez ten podmiot.
Przerzuć również Odwraca wartość logiczna elementu vector.
Przykład
// 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;
}
Wymagania
Nagłówek: <vector>
Obszar nazw: std