首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

operators (std::bitset)

template< std::size_t N > bitset<N> operator&( const bitset<N>& lhs, const bitset<N>& rhs );

(1)

?

template< std::size_t N > bitset<N> operator|( const bitset<N>& lhs, const bitset<N>& rhs );

(2)

?

template< std::size_t N > bitset<N> operator^( const bitset<N>& lhs, const bitset<N>& rhs );

(3)

?

在两个位集之间执行二进制和、OR和XOR,lhsrhs...

1%29bitset<N>包含二进制结果和相应的位对的lhsrhs...

2%29bitset<N>的对应位对上的二进制或的结果。lhsrhs...

3%29bitset<N>的对应位对上包含二进制异或的结果。lhsrhs...

参数

lhs

-

the bitset on the left-hand side of the operator

rhs

-

the bitset on the right-hand side of the operator

返回值

1%29bitset<N>(lhs) &= rhs

2%29bitset<N>(lhs) |= rhs

3%29bitset<N>(lhs) ^= rhs

例外

(none)

(until C++11)

noexcept specification: noexcept

(since C++11)

二次

代码语言:javascript
复制
#include <bitset>
#include <iostream>
 
int main()
{
    std::bitset<4> b1("0110");
    std::bitset<4> b2("0011");
    std::cout << "b1 & b2: " << (b1 & b2) << '\n';
    std::cout << "b1 | b2: " << (b1 | b2) << '\n';
    std::cout << "b1 ^ b2: " << (b1 ^ b2) << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
b1 & b2: 0010
b1 | b2: 0111
b1 ^ b2: 0101

二次

另见

operator&=operator|=operator^=operator~

performs binary AND, OR, XOR and NOT (public member function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com