vector<bool>::reference::flip

反转向量元素的布尔值。

void flip( );

备注

引用operator~ 还反转向量元素的布尔值。

示例

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

class MyAlloc{};
int main( ) 
{
   using namespace std;
   typedef vector<bool> boolvector;
   boolvector v;

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

   cout << "The original value of the 1st element is: " << bool( ref1 ) << endl;
   ref1.flip( );
   cout << "The value of the 1st element is now: " << ref1 << endl;
}
  

要求

标头: <vector>

命名空间: std

请参见

参考

vector<bool>::reference Class

标准模板库