bitset::size

bitset のオブジェクトのビット数を返します。

size_t size( ) const;

戻り値

ビット数、**bitset<N>**の N

使用例

/Wp64 フラグを持つまたは 64 ビット プラットフォームでこの例をコンパイルすると、コンパイラの警告 C4267 エラーが生成されます。この警告の詳細については、コンパイラの警告 (レベル 3) C4267を参照してください。

// bitset_size.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>

int main()
{
    using namespace std;

    bitset<5> b1(6);
    size_t i;

    cout << "The set of bits in bitset<5> b1( 6 ) is: ( "<< b1 << " )"
         << endl;

    i = b1.size();

    cout << "The number of bits in bitset b1 is: " << i << "."
         << endl;
}
  

必要条件

ヘッダー: <bitset>

名前空間: std

参照

関連項目

bitset Class