CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 23 Jul 2025 09:34:12 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/bitset/bitset/operators/
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 23 Jul 2025 09:34:12 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"7f68-bCTqRzsQzwl2SMB331Q4A/OKV3E"
Content-Encoding: gzip
Performs the proper bitwise operation using the contents of the bitset.
Otherwise: the result of the operation (either a bitset object, or
Output:
The other operations never throw exceptions (no-throw guarantee).
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
bitset
- bitset::bitset
- bitset operators
member classes
member functions
non-member specializations
-
hash<bitset>C++11
-
function
<bitset>
std::bitset operators
member functions | bitset& operator&= (const bitset& rhs);bitset& operator|= (const bitset& rhs);bitset& operator^= (const bitset& rhs);bitset& operator<<= (size_t pos);bitset& operator>>= (size_t pos);bitset operator~() const;bitset operator<<(size_t pos) const;bitset operator>>(size_t pos) const;bool operator== (const bitset& rhs) const;bool operator!= (const bitset& rhs) const; |
---|---|
non-member functions | template<size_t N> bitset<N> operator& (const bitset<N>& lhs, const bitset<N>& rhs);template<size_t N> bitset<N> operator| (const bitset<N>& lhs, const bitset<N>& rhs);template<size_t N> bitset<N> operator^ (const bitset<N>& lhs, const bitset<N>& rhs); |
iostream inserters/extractors | template<class charT, class traits, size_t N> basic_istream<charT, traits>& operator>> (basic_istream<charT,traits>& is, bitset<N>& rhs);template<class charT, class traits, size_t N> basic_ostream<charT, traits>& operator<< (basic_ostream<charT,traits>& os, const bitset<N>& rhs); |
member functions | bitset& operator&= (const bitset& rhs) noexcept;bitset& operator|= (const bitset& rhs) noexcept;bitset& operator^= (const bitset& rhs) noexcept;bitset& operator<<= (size_t pos) noexcept;bitset& operator>>= (size_t pos) noexcept;bitset operator~() const noexcept;bitset operator<<(size_t pos) const noexcept;bitset operator>>(size_t pos) const noexcept;bool operator== (const bitset& rhs) const noexcept;bool operator!= (const bitset& rhs) const noexcept; |
---|---|
non-member functions | template<size_t N> bitset<N> operator& (const bitset<N>& lhs, const bitset<N>& rhs) noexcept;template<size_t N> bitset<N> operator| (const bitset<N>& lhs, const bitset<N>& rhs) noexcept;template<size_t N> bitset<N> operator^ (const bitset<N>& lhs, const bitset<N>& rhs) noexcept; |
iostream inserters/extractors | template<class charT, class traits, size_t N> basic_istream<charT, traits>& operator>> (basic_istream<charT,traits>& is, bitset<N>& rhs);template<class charT, class traits, size_t N> basic_ostream<charT, traits>& operator<< (basic_ostream<charT,traits>& os, const bitset<N>& rhs); |
Bitset operators
Parameters
- lhs
- Left-hand side bitset object (for non-member functions).
- rhs
- Right-hand side bitset object.
Both the left-hand side and right-hand side bitset objects must have the same amount of bits (i.e., have the same class template parameter, N). - pos
- Number of bit locations to be shifted.
- is,os
- basic_istream or basic_ostream object from which a bitset object is respectively extracted or inserted. The format in which bitsets are inserted/extracted is a sequence of (suitably widened)
'0'
and'1'
characters.
Return value
If a reference: the left-hand side object (*this
, is or os).Otherwise: the result of the operation (either a bitset object, or
true
or false
for the relational operators).Example
|
|
Output:
1010 0010 0011 1100 0110 1100 0110 0001 0 1 0010 0111 0101 |
Data races
All bit position in the bitset objects involved in the operation are accessed, and -if in a compound assignment- also modified.Exception safety
The stream inserter/extractors leave all objects in a valid state in case of exception (basic guarantee).The other operations never throw exceptions (no-throw guarantee).
See also
- bitset::operator[]
- Access bit (public member function)
- bitset::set
- Set bits (public member function)
- bitset::reset
- Reset bits (public member function)
- bitset::flip
- Flip bits (public member function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us