C++ 關鍵字: xor_eq
來自 cppreference.com
[編輯] 用法
- 替代運算子: 作為
^=
的替代
[編輯] 示例
執行此程式碼
#include <bitset> #include <iostream> using bin = std::bitset<8>; void show(bin z, const char* s, int n) { if (n == 0) std::cout << "┌────────────┬──────────┐\n"; if (n <= 2) std::cout << "│ " <<s<< " │ " <<z<<" │\n"; if (n == 2) std::cout << "└────────────┴──────────┘\n"; } int main() { bin x{"01011010"}; show(x, "x ", 0); bin y{"00111100"}; show(y, "y ", 1); x xor_eq y; show(x, "x xor_eq y", 2); }
輸出
┌────────────┬──────────┐ │ x │ 01011010 │ │ y │ 00111100 │ │ x xor_eq y │ 01100110 │ └────────────┴──────────┘