[bitset.operators] # 22 General utilities library [[utilities]](./#utilities) ## 22.9 Bitsets [[bitset]](bitset#operators) ### 22.9.4 bitset operators [bitset.operators] [🔗](#lib:operator&,bitset) `template constexpr bitset operator&(const bitset& lhs, const bitset& rhs) noexcept; ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11121) *Returns*: bitset(lhs) &= rhs[.](#1.sentence-1) [🔗](#lib:operator%7c,bitset) `template constexpr bitset operator|(const bitset& lhs, const bitset& rhs) noexcept; ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11133) *Returns*: bitset(lhs) |= rhs[.](#2.sentence-1) [🔗](#lib:operator%5e,bitset) `template constexpr bitset operator^(const bitset& lhs, const bitset& rhs) noexcept; ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11145) *Returns*: bitset(lhs) ^= rhs[.](#3.sentence-1) [🔗](#lib:operator%3e%3e,bitset) `template basic_istream& operator>>(basic_istream& is, bitset& x); ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11158) A formatted input function ([[istream.formatted]](istream.formatted "31.7.5.3 Formatted input functions"))[.](#4.sentence-1) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11161) *Effects*: Extracts up to N characters from is[.](#5.sentence-1) Stores these characters in a temporary object str of typebasic_string, then evaluates the expressionx = bitset(str)[.](#5.sentence-2) Characters are extracted and stored until any of the following occurs: - [(5.1)](#5.1) N characters have been extracted and stored; - [(5.2)](#5.2) end-of-file occurs on the input sequence; - [(5.3)](#5.3) the next input character is neitheris.widen('0') noris.widen('1') (in which case the input character is not extracted)[.](#5.sentence-3) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11183) If N > 0 and no characters are stored in str,ios_base​::​failbit is set in the input function's local error state before setstate is called[.](#6.sentence-1) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11188) *Returns*: is[.](#7.sentence-1) [🔗](#lib:operator%3c%3c,bitset) `template basic_ostream& operator<<(basic_ostream& os, const bitset& x); ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11201) *Returns*: os << x.template to_string>( use_facet>(os.getloc()).widen('0'), use_facet>(os.getloc()).widen('1')) (see [[ostream.formatted]](ostream.formatted "31.7.6.3 Formatted output functions"))[.](#8.sentence-1)