bitset::element_type
데이터 형식에 대 한 동의어 형식 bool 요소 비트는 bitset에 참조를 사용할 수 있습니다.
typedef bool element_type;
예제
// bitset_elem_type.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
int main( )
{
using namespace std;
bitset<3> b1 ( 2 );
cout << "Original bitset b1(6) is: ( "<< b1 << " )"
<< endl;
//Compare two ways to reference bits in a bitset
bool b;
bitset<5>::element_type e;
b = b1.test ( 2 );
if ( b )
cout << "The bit at position 2 of bitset b1"
<< "has a value of 1." << endl;
else
cout << "The bit at position 2 of bitset b1"
<< "has a value of 0." << endl;
b1[2] = 1;
cout << "Bitset b1 modified by b1[2] = 1 is: ( "<< b1 << " )"
<< endl;
e = b1.test ( 2 );
if ( e )
cout << "The bit at position 2 of bitset b1"
<< "has a value of 1." << endl;
else
cout << "The bit at position 2 of bitset b1"
<< "has a value of 0." << endl;
}
요구 사항
헤더: <bitset>
네임 스페이스: std