다음을 통해 공유


vector<bool>::reference::operator bool

Casts a variable of vector<bool>::reference.

operator bool( ) const;

Return Value

The Boolean value of the element of the vector.

Remarks

The vector object cannot be modified by this operator.

Example

// 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;
}
0
0
0

Requirements

Header: <vector>

Namespace: std

See Also

Reference

vector<bool>::reference Class

Standard Template Library

Other Resources

vector<bool>::reference Members