vector<bool>::reference::operator bool
변수 벡터 <bool>의 캐스팅:: 참조.
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