名前空間
変種
操作

std::bitset::operator[]

提供: cppreference.com
< cpp‎ | utility‎ | bitset

 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
std::bitset
メンバータイプ
Original:
Member types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::reference
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::bitset
bitset::operator==
bitset::operator!=
要素アクセスの循環参照を解除するために使用されている
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator[]
bitset::test
bitset::all
bitset::any
bitset::none
(C++11)

 
bitset::count
容量
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::size
修飾子
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator&=
bitset::operator|=
bitset::operator^=
bitset::operator~
bitset::operator<<=
bitset::operator>>=
bitset::operator<<
bitset::operator>>
bitset::set
bitset::reset
bitset::flip
変換
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::to_string
bitset::to_ulong
bitset::to_ullong(C++11)
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator&
operator|
operator^
operator<<
operator>>
ヘルパークラス
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::hash(C++11)
 
bool operator[]( std::size_t pos ) const;
constexpr bool operator[]( std::size_t pos ) const;
(1) (C++11以前)
(C++11およびそれ以降)
reference operator[]( std::size_t pos );
(2)
位置posのビットにアクセスします。最初のバージョンは、ビットの値を返し、2番目のバージョンでは、値を変更できるタイプstd::bitset::referenceのオブジェクトを返します。.
Original:
Accesses the bit at position pos. The first version returns the value of the bit, the second version returns an object of type std::bitset::reference that allows modification of the value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
test()は異なり、例外をスローしません:posが範囲外にある場合の動作は未定義です.
Original:
Unlike test(), does not throw exceptions: the behavior is undefined if pos is out of bounds.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

pos -
ビットの位置が戻ります
Original:
position of the bit to return
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

1)
要求されたビットの値
Original:
the value of the requested bit
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
要求されたビットへの書き込みを可能にするタイプのstd::bitset::referenceのオブジェクト.
Original:
an object of type std::bitset::reference, which allows writing to the requested bit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 例外

なし
Original:
None
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <bitset>
 
int main()
{
    std::bitset<8> b1(42);
    for (std::size_t i = 0; i < b1.size(); ++i) {
        std::cout << "b1[" << i << "]: " << b1[i] << '\n';
    }
    b1[0] = true; // modifies the first bit through bitset::refence
    std::cout << "After setting bit 0, the bitset holds " << b1 << '\n';
}

Output:

b1[0]: 0
b1[1]: 1
b1[2]: 0
b1[3]: 1
b1[4]: 0
b1[5]: 1
b1[6]: 0
b1[7]: 0
After setting bit 0, bitset is 00101011

[編集] も参照してください

特定のビットにアクセスします
Original:
accesses specific bit
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数) [edit]