[bitwise.operations] # 22 General utilities library [[utilities]](./#utilities) ## 22.10 Function objects [[function.objects]](function.objects#bitwise.operations) ### 22.10.11 Bitwise operations [bitwise.operations] #### [22.10.11.1](#general) General [[bitwise.operations.general]](bitwise.operations.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12931) The library provides basic function object classes for all of the bitwise operators in the language ([[expr.bit.and]](expr.bit.and "7.6.11 Bitwise AND operator"), [[expr.or]](expr.or "7.6.13 Bitwise inclusive OR operator"), [[expr.xor]](expr.xor "7.6.12 Bitwise exclusive OR operator"), [[expr.unary.op]](expr.unary.op "7.6.2.2 Unary operators"))[.](#general-1.sentence-1) #### [22.10.11.2](#and) Class template bit_and [[bitwise.operations.and]](bitwise.operations.and) [🔗](#lib:bit_and) `template struct bit_and { constexpr T operator()(const T& x, const T& y) const; }; ` [🔗](#lib:operator(),bit_and) `constexpr T operator()(const T& x, const T& y) const; ` [1](#and-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12950) *Returns*: x & y[.](#and-1.sentence-1) [🔗](#lib:bit_and%3c%3e) `template<> struct bit_and { template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) & std::forward(u)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),bit_and%3c%3e) `template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) & std::forward(u)); ` [2](#and-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12972) *Returns*: std​::​forward(t) & std​::​forward(u)[.](#and-2.sentence-1) #### [22.10.11.3](#or) Class template bit_or [[bitwise.operations.or]](bitwise.operations.or) [🔗](#lib:bit_or) `template struct bit_or { constexpr T operator()(const T& x, const T& y) const; }; ` [🔗](#lib:operator(),bit_or) `constexpr T operator()(const T& x, const T& y) const; ` [1](#or-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12992) *Returns*: x | y[.](#or-1.sentence-1) [🔗](#lib:bit_or%3c%3e) `template<> struct bit_or { template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) | std::forward(u)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),bit_or%3c%3e) `template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) | std::forward(u)); ` [2](#or-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13014) *Returns*: std​::​forward(t) | std​::​forward(u)[.](#or-2.sentence-1) #### [22.10.11.4](#xor) Class template bit_xor [[bitwise.operations.xor]](bitwise.operations.xor) [🔗](#lib:bit_xor) `template struct bit_xor { constexpr T operator()(const T& x, const T& y) const; }; ` [🔗](#lib:operator(),bit_xor) `constexpr T operator()(const T& x, const T& y) const; ` [1](#xor-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13034) *Returns*: x ^ y[.](#xor-1.sentence-1) [🔗](#lib:bit_xor%3c%3e) `template<> struct bit_xor { template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) ^ std::forward(u)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),bit_xor%3c%3e) `template constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) ^ std::forward(u)); ` [2](#xor-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13056) *Returns*: std​::​forward(t) ^ std​::​forward(u)[.](#xor-2.sentence-1) #### [22.10.11.5](#not) Class template bit_not [[bitwise.operations.not]](bitwise.operations.not) [🔗](#not-itemdecl:1) `template struct bit_not { constexpr T operator()(const T& x) const; }; ` [🔗](#lib:operator(),bit_not) `constexpr T operator()(const T& x) const; ` [1](#not-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13075) *Returns*: ~x[.](#not-1.sentence-1) [🔗](#lib:bit_not%3c%3e) `template<> struct bit_not { template constexpr auto operator()(T&& t) const -> decltype(~std::forward(t)); using is_transparent = unspecified; }; ` [🔗](#lib:operator(),bit_not%3c%3e) `template constexpr auto operator()(T&& t) const -> decltype(~std::forward(t)); ` [2](#not-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13097) *Returns*: ~std​::​forward(t)[.](#not-2.sentence-1)