Export (0) Print
Expand All

operator| (<bitset>)

Performs a bitwise OR between two bitsets.

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

_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.

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

// 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

Header: <bitset>

Namespace: std

Show:
© 2014 Microsoft