vector<bool>::reference::operator bool

转换向量<bool>::reference的变量。

operator bool( ) const;

返回值

向量元素的布尔值。

备注

向量对象不能由此运算符修改。

示例

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

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

   v.push_back( false );
   boolvector::reference ref1 = v.at( 0 );
   cout << ref1 << endl;   // ref1 implicitly cast to bool 

   bool b1; 

   // One form of an explicit cast
   b1 = ref1.operator bool( );
   cout << b1 << endl; 

   // Another form of an explicit cast
   b1 = bool( ref1 );
   cout << b1 << endl;
}
  

要求

标头: <vector>

命名空间: std

请参见

参考

vector<bool>::reference Class

标准模板库