命名空间
变体
操作

C++ 关键字: bitor

来自 cppreference.cn
< cpp‎ | keyword
 
 
C++ 语言
通用主题
流程控制
条件执行语句
if
迭代语句 (循环)
for
范围 for (C++11)
跳转语句
函数
函数声明
Lambda 函数表达式
inline 说明符
动态异常规范 (在 C++17* 中已弃用)
noexcept 说明符 (C++11)
异常
命名空间
类型
说明符
const/volatile
decltype (C++11)
auto (C++11)
constexpr (C++11)
consteval (C++20)
constinit (C++20)
存储期说明符
初始化
 
 

[编辑] 用法

[编辑] 示例

#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);
    bin z = x bitor y; show(z, "x bitor y", 2);
}

输出

┌───────────┬──────────┐
│ x         │ 01011010 │
│ y         │ 00111100 │
│ x bitor y │ 01111110 │
└───────────┴──────────┘

[编辑] 另请参阅