名前空間
変種

operator==,!=(std::bitset)

提供: cppreference.com
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (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)
 
 
<tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody> <tbody class="t-dcl-rev t-dcl-rev-num "> </tbody><tbody> </tbody>
(1)
bool operator==( const bitset<N>& rhs ) const;
(C++11未満)
bool operator==( const bitset<N>& rhs ) const noexcept;
(C++11以上)
(2)
bool operator!=( const bitset<N>& rhs ) const;
(C++11未満)
bool operator!=( const bitset<N>& rhs ) const noexcept;
(C++11以上)
(C++20未満)
1) *thisrhs のすべてのビットが等しければ true を返します。
2) *thisrhs のいずれかのビットが等しくなければ true を返します。

引数

rhs - 比較するビットセット

戻り値

1) *this 内の各ビットの値が rhs 内の対応するビットの値と等しければ true、そうでなければ false
2) !(*this == rhs) であれば true、そうでなければ false

2つのビットセットが同一かどうかを調べるために比較します。

#include <iostream>
#include <bitset>

int main()
{
    std::bitset<4> b1(3); // [0,0,1,1]
    std::bitset<4> b2(b1);
    std::bitset<4> b3(4); // [0,1,0,0]

    std::cout << "b1 == b2: " << (b1 == b2) << '\n';
    std::cout << "b1 == b3: " << (b1 == b3) << '\n';
    std::cout << "b1 != b3: " << (b1 != b3) << '\n';
}

出力:

b1 == b2: 1
b1 == b3: 0
b1 != b3: 1
Morty Proxy This is a proxified and sanitized view of the page, visit original site.