C++ 位集庫 - operator>> 函式



描述

C++ 函式std::bitset::operator>> 對bitset 執行按位右移操作。

宣告

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

C++98

bitset operator>>(size_t pos) const;

C++11

bitset operator>>(size_t pos) const noexcept;

引數

pos − 要移位的位數。

返回值

返回一個新的bitset物件,其中包含移位的位。

異常

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

示例

以下示例演示了 std::bitset::operator>> 函式的用法。

#include <iostream>
#include <bitset>

using namespace std;

int main(void) {

   bitset<4> b("1000");

   auto result = b >> 1;

   cout << result << endl;

   return 0;
}

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

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