Partilhar via


operator| (<bitset>)

Performs a bitwise OR between two bitsets.

template <size_t size>
bitset<size> operator|(
   const bitset<size>& _Left,
   const bitset<size>& _Right
);

Parameters

  • _Left
    The first of the two bitsets whose respective elements are to be combined with the bitwise OR.

  • _Right
    The second of the two valarrays whose respective elements are to be combined with the bitwise OR.

Return Value

A bitset whose elements are the result of performing the OR operation on the corresponding elements of _Left and _Right.

Example

// bitset_or.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
#include <string>

using namespace std;

int main()
{
   bitset<4> b1 ( string("0101") );
   bitset<4> b2 ( string("0011") );
   bitset<4> b3 = b1 | b2;
   cout << "bitset 1: " << b1 << endl;
   cout << "bitset 2: " << b2 << endl;
   cout << "bitset 3: " << b3 << endl;
}
bitset 1: 0101
bitset 2: 0011
bitset 3: 0111

Requirements

Header: <bitset>

Namespace: std

See Also

Other Resources

<bitset> Members