Files
2025-10-25 03:02:53 +03:00

185 lines
5.0 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.11Bitwise AND operator"), [[expr.or]](expr.or "7.6.13Bitwise inclusive OR operator"), [[expr.xor]](expr.xor "7.6.12Bitwise exclusive OR operator"), [[expr.unary.op]](expr.unary.op "7.6.2.2Unary operators"))[.](#general-1.sentence-1)
#### [22.10.11.2](#and) Class template bit_and [[bitwise.operations.and]](bitwise.operations.and)
[🔗](#lib:bit_and)
`template<class T = void> 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<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) & std::forward<U>(u));
using is_transparent = unspecified;
};
`
[🔗](#lib:operator(),bit_and%3c%3e)
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) & std::forward<U>(u));
`
[2](#and-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12972)
*Returns*: std::forward<T>(t) & std::forward<U>(u)[.](#and-2.sentence-1)
#### [22.10.11.3](#or) Class template bit_or [[bitwise.operations.or]](bitwise.operations.or)
[🔗](#lib:bit_or)
`template<class T = void> 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<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) | std::forward<U>(u));
using is_transparent = unspecified;
};
`
[🔗](#lib:operator(),bit_or%3c%3e)
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) | std::forward<U>(u));
`
[2](#or-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13014)
*Returns*: std::forward<T>(t) | std::forward<U>(u)[.](#or-2.sentence-1)
#### [22.10.11.4](#xor) Class template bit_xor [[bitwise.operations.xor]](bitwise.operations.xor)
[🔗](#lib:bit_xor)
`template<class T = void> 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<void> {
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) ^ std::forward<U>(u));
using is_transparent = unspecified;
};
`
[🔗](#lib:operator(),bit_xor%3c%3e)
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
-> decltype(std::forward<T>(t) ^ std::forward<U>(u));
`
[2](#xor-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13056)
*Returns*: std::forward<T>(t) ^ std::forward<U>(u)[.](#xor-2.sentence-1)
#### [22.10.11.5](#not) Class template bit_not [[bitwise.operations.not]](bitwise.operations.not)
[🔗](#not-itemdecl:1)
`template<class T = void> 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<void> {
template<class T> constexpr auto operator()(T&& t) const
-> decltype(~std::forward<T>(t));
using is_transparent = unspecified;
};
`
[🔗](#lib:operator(),bit_not%3c%3e)
`template<class T> constexpr auto operator()(T&& t) const
-> decltype(~std::forward<T>(t));
`
[2](#not-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13097)
*Returns*: ~std::forward<T>(t)[.](#not-2.sentence-1)