C++ 关键词:xor_eq
来自cppreference.com
用法
- 代用运算符:用作
^=的替代写法
示例
Run this code
#include <iostream>
#include <bitset>
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 │
└────────────┴──────────┘