描述
C++ 函數std::bitset::set()將 bitset 中的所有位設置為 1。
聲明
以下是 std::bitset::set() 函數形式 std::bitset 標頭的聲明。
C++98
bitset& set();
C++11
bitset& set() constexpr;
參數
空
返回值
返回這個指針。
異常
此成員函數從不拋出異常。
示例
下麵的例子展示了 std::bitset::set() 函數的用法。
#include <iostream>
#include <bitset>
using namespace std;
int main(void) {
bitset<4> b;
cout << "Before set operation b = " << b << endl;
b.set();
cout << "After set operation b = " << b << endl;
return 0;
}
讓我們編譯並運行上麵的程序,這將產生以下結果——
Before set operation b = 0000 After set operation b = 1111
相關用法
- C++ Bitset set()用法及代碼示例
- C++ Bitset reference()用法及代碼示例
- C++ Bitset reset()用法及代碼示例
- C++ Bitset hash()用法及代碼示例
- C++ Bitset to_string()用法及代碼示例
- C++ Bitset bitset()用法及代碼示例
- C++ Bitset test()用法及代碼示例
- C++ Bitset to_ulong()用法及代碼示例
- C++ Bitset all()用法及代碼示例
- C++ Bitset any()用法及代碼示例
- C++ Bitset none()用法及代碼示例
- C++ Bitset to_ullong()用法及代碼示例
- C++ Bitset flip()用法及代碼示例
- C++ Bitset count()用法及代碼示例
- C++ Boost.Lexical_Cast用法及代碼示例
- C++ unordered_map cbegin用法及代碼示例
- C++ map lower_bound()用法及代碼示例
- C++ Unordered_multimap reserve()用法及代碼示例
- C++ list assign()用法及代碼示例
- C++ std::max()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Bitset Library - set() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。