operator==,!=(std::bitset)
Aus cppreference.com
<metanoindex/>
<tbody> </tbody> bool operator==( const bitset<N>& rhs ); |
(1) | |
bool operator!=( const bitset<N>& rhs ); |
(2) | |
1)
Liefert true, wenn alle Bits in
*this und rhs gleich .Original:
Returns true if all of the bits in
*this and rhs are equal.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
Liefert true, wenn eines der Bits in
*this und rhs sind nicht gleich .Original:
Returns true if any of the bits in
*this and rhs are not equal.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
Rückgabewert
1)
true wenn der Wert jedes Bits in *this gleich dem Wert des entsprechenden Bits in rhs, sonst falseOriginal:
true if the value of each bit in *this equals the value of the corresponding bit in rhs, otherwise falseThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
true wenn , sonst falseOriginal:
true if , otherwise falseThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
Vergleich zweier BitSets um festzustellen, ob sie identisch sind:
Original:
Compare two bitsets to determine if they are identical:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#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';
}
Output:
b1 == b2: 1
b1 == b3: 0
b1 != b3: 1
