std::bitset<N>::operator&=,|=,^=,~
提供: cppreference.com
(1) | ||
bitset<N>& operator&=( const bitset<N>& other ); |
(C++11未満) | |
bitset<N>& operator&=( const bitset<N>& other ) noexcept; |
(C++11以上) | |
(2) | ||
bitset<N>& operator|=( const bitset<N>& other ); |
(C++11未満) | |
bitset<N>& operator|=( const bitset<N>& other ) noexcept; |
(C++11以上) | |
(3) | ||
bitset<N>& operator^=( const bitset<N>& other ); |
(C++11未満) | |
bitset<N>& operator^=( const bitset<N>& other ) noexcept; |
(C++11以上) | |
(4) | ||
bitset<N> operator~() const; |
(C++11未満) | |
bitset<N> operator~() const noexcept; |
(C++11以上) | |
バイナリ論理積、論理和、排他的論理和および論理否定を行います。
1) ビットを
*this
と other
の対応するビットの組に対するバイナリ論理積の結果に設定します。2) ビットを
*this
と other
の対応するビットの組に対するバイナリ論理和の結果に設定します。3) ビットを
*this
と other
の対応するビットの組に対するバイナリ排他的論理和の結果に設定します。4) すべてのビットを反転 (バイナリ論理否定) した
*this
の一時的なコピーを返します。&=、|=、^= は同じサイズ N
のビットセットに対してのみ定義されることに注意してください。
目次 |
[編集] 引数
other | - | 別のビットセット |
[編集] 戻り値
1-3) *this。
4) bitset<N>(*this).flip()。
[編集] 例
Run this code
#include <iostream> #include <string> #include <bitset> int main() { std::bitset<16> dest; std::string pattern_str = "1001"; std::bitset<16> pattern(pattern_str); for (size_t i = 0, ie = dest.size()/pattern_str.size(); i != ie; ++i) { dest <<= pattern_str.size(); dest |= pattern; } std::cout << dest << '\n'; }
出力:
1001100110011001
[編集] 関連項目
バイナリ左シフトおよび右シフトを行います (パブリックメンバ関数) |