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

5.0 KiB
Raw Permalink Blame History

[bitwise.operations]

22 General utilities library [utilities]

22.10 Function objects [function.objects]

22.10.11 Bitwise operations [bitwise.operations]

22.10.11.1 General [bitwise.operations.general]

1

#

The library provides basic function object classes for all of the bitwise operators in the language ([expr.bit.and], [expr.or], [expr.xor], [expr.unary.op]).

22.10.11.2 Class template bit_and [bitwise.operations.and]

🔗

template<class T = void> struct bit_and { constexpr T operator()(const T& x, const T& y) const; };

🔗

constexpr T operator()(const T& x, const T& y) const;

1

#

Returns: x & y.

🔗

`template<> struct bit_and { template<class T, class U> constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) & std::forward(u));

using is_transparent = unspecified; }; `

🔗

template<class T, class U> constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward<T>(t) & std::forward<U>(u));

2

#

Returns: std::forward(t) & std::forward(u).

22.10.11.3 Class template bit_or [bitwise.operations.or]

🔗

template<class T = void> struct bit_or { constexpr T operator()(const T& x, const T& y) const; };

🔗

constexpr T operator()(const T& x, const T& y) const;

1

#

Returns: x | y.

🔗

`template<> struct bit_or { template<class T, class U> constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) | std::forward(u));

using is_transparent = unspecified; }; `

🔗

template<class T, class U> constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward<T>(t) | std::forward<U>(u));

2

#

Returns: std::forward(t) | std::forward(u).

22.10.11.4 Class template bit_xor [bitwise.operations.xor]

🔗

template<class T = void> struct bit_xor { constexpr T operator()(const T& x, const T& y) const; };

🔗

constexpr T operator()(const T& x, const T& y) const;

1

#

Returns: x ^ y.

🔗

`template<> struct bit_xor { template<class T, class U> constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward(t) ^ std::forward(u));

using is_transparent = unspecified; }; `

🔗

template<class T, class U> constexpr auto operator()(T&& t, U&& u) const -> decltype(std::forward<T>(t) ^ std::forward<U>(u));

2

#

Returns: std::forward(t) ^ std::forward(u).

22.10.11.5 Class template bit_not [bitwise.operations.not]

🔗

template<class T = void> struct bit_not { constexpr T operator()(const T& x) const; };

🔗

constexpr T operator()(const T& x) const;

1

#

Returns: ~x.

🔗

`template<> struct bit_not { template constexpr auto operator()(T&& t) const -> decltype(~std::forward(t));

using is_transparent = unspecified; }; `

🔗

template<class T> constexpr auto operator()(T&& t) const -> decltype(~std::forward<T>(t));

2

#

Returns: ~std::forward(t).