bitset::operator==

测试相等性目标bitset与指定的bitset。

bool operator ==(
   const bitset<N>& _Right
) const;

参数

  • _Right
    将与相等的目标bitset比较的bitset。

返回值

true,如果bitsets相同; false,如果它们是不同的。

备注

Bitsets必须为相等要测试的大小相同跟成员运算符函数。

示例

// bitset_op_EQ.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>

int main( )
{
   using namespace std;
   bitset<5> b1 ( 7 );
   bitset<5> b2 ( 7 );
   bitset<5> b3 ( 2 );
   bitset<4> b4 ( 7 );

   if ( b1 == b2 )
      cout << "Bitset b1 is the same as bitset b2." << endl;
   else
      cout << "Bitset b1 is different from bitset b2." << endl;

   if ( b1 == b3 )
      cout << "Bitset b1 is the same as bitset b3." << endl;
   else
      cout << "Bitset b1 is different from bitset b3." << endl;

   // This would cause an error because bitsets must have the 
   // same size to be tested
   // if ( b1 == b4 )
   //   cout << "Bitset b1 is the same as bitset b4." << endl;
   // else
   //   cout << "Bitset b1 is different from bitset b4." << endl;
}
  
  

要求

标头: <bitset>

命名空间: std

请参见

参考

bitset Class