名前空間
変種
操作

operator&,|,^(std::bitset)

提供: cppreference.com
< cpp‎ | utility‎ | bitset
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
 
(1)
template< std::size_t N >
bitset<N> operator&( const bitset<N>& lhs, const bitset<N>& rhs );
(C++11未満)
template< std::size_t N >
bitset<N> operator&( const bitset<N>& lhs, const bitset<N>& rhs ) noexcept;
(C++11以上)
(2)
template< std::size_t N >
bitset<N> operator|( const bitset<N>& lhs, const bitset<N>& rhs );
(C++11未満)
template< std::size_t N >
bitset<N> operator|( const bitset<N>& lhs, const bitset<N>& rhs ) noexcept;
(C++11以上)
(3)
template< std::size_t N >
bitset<N> operator^( const bitset<N>& lhs, const bitset<N>& rhs );
(C++11未満)
template< std::size_t N >
bitset<N> operator^( const bitset<N>& lhs, const bitset<N>& rhs ) noexcept;
(C++11以上)

2つのビットセット lhsrhs の間でバイナリ論理積、論理和、排他的論理和を行います。

1) lhsrhs の対応するビットの組に対するバイナリ論理積の結果を格納する bitset<N> を返します。
2) lhsrhs の対応するビットの組に対するバイナリ論理和の結果を格納する bitset<N> を返します。
3) lhsrhs の対応するビットの組に対するバイナリ排他的論理和の結果を格納する bitset<N> を返します。

目���

[編集] 引数

lhs - 演算子の左側のビットセット
rhs - 演算子の右側のビットセット

[編集] 戻り値

1) bitset<N>(lhs) &= rhs
2) bitset<N>(lhs) |= rhs
3) bitset<N>(lhs) ^= rhs

[編集]

#include <bitset>
#include <iostream>
 
int main()
{
    std::bitset<4> b1("0110");
    std::bitset<4> b2("0011");
    std::cout << "b1 & b2: " << (b1 & b2) << '\n';
    std::cout << "b1 | b2: " << (b1 | b2) << '\n';
    std::cout << "b1 ^ b2: " << (b1 ^ b2) << '\n';
}

出力:

b1 & b2: 0010
b1 | b2: 0111
b1 ^ b2: 0101

[編集] 関連項目

バイナリ論理積、論理和、排他的論理和、論理否定を行います
(パブリックメンバ関数) [edit]