Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Returns a Boolean value that is the opposite of that held by the element referenced.
bool operator~( ) const;
Return Value
The inverted Boolean value of the vector element.
Remarks
The vector object cannot be modified by this operator.
flip also inverts the Boolean value of a vector element.
Example
// 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;
}
Value of inverted 1st element obtained is: 1 Value of 1st element in vector is still: 0 Value of inverted 2nd element obtained is: 0 Value of 2nd element in vector is still: 1
Requirements
Header: <vector>
Namespace: std