C++ 位集庫 - operator<<= 函式



描述

C++ 函式std::bitset::operator<<= 對當前位集物件執行按位左移操作。

宣告

以下是來自 <bitset> 標頭檔案的 std::bitset::operator<<= 函式宣告。

C++98

bitset& operator<<= (size_t pos);

C++11

bitset& operator<<= (size_t pos) noexcept;

引數

pos − 要移位的位數。

返回值

返回this指標。

異常

此成員函式從不丟擲異常。

示例

以下示例顯示了 std::bitset::operator<<= 函式的使用方法。

#include <iostream>
#include <bitset>

using namespace std;

int main(void) {
   bitset<4> b("0001");

   b <<= 1;

   cout << b << endl;

   return 0;
}

讓我們編譯並執行上面的程式,這將產生以下結果:

0010
bitset.htm
廣告
© . All rights reserved.