bitset<N>& operator&=( const bitset<N>& other ); | (1) | |
bitset<N>& operator|=( const bitset<N>& other ); | (2) | |
bitset<N>& operator^=( const bitset<N>& other ); | (3) | |
bitset<N> operator~() const; | (4) |
Performs binary AND, OR, XOR and NOT.
*this
and other
.*this
and other
.*this
and other
.*this
with all bits flipped (binary NOT).Note that &=, |=, and ^= are only defined for bitsets of the same size N
.
other | - | another bitset |
*this
bitset<N>(*this).flip()
(none) | (until C++11) |
noexcept specification: noexcept | (since C++11) |
#include <iostream> #include <string> #include <bitset> int main() { std::bitset<16> dest; std::string pattern_str = "1001"; std::bitset<16> pattern(pattern_str); for (size_t i = 0, ie = dest.size()/pattern_str.size(); i != ie; ++i) { dest <<= pattern_str.size(); dest |= pattern; } std::cout << dest << '\n'; }
Output:
1001100110011001
performs binary shift left and shift right (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/utility/bitset/operator_logic