std::bit_or(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

okay bestie, welcome to std::bit_or(3) from the C++ Standard Libary β€” yep, β€œLibary” is literally how the header spells it, and we respect the source πŸ˜­πŸ’…

🌸 NAME 🌸

std::bit_or β€” std::bit_or. That’s the name, that’s the whole name, main character energy from the jump πŸ‘‘βœ¨


✨ Synopsis ✨

Defined in header <functional> β€” noted, bestie 🫢

template< class T >             (until C++14)
struct bit_or;
template< class T = void >      (since C++14)
struct bit_or;

Function object for performing bitwise OR. Effectively calls operator| on type T. slay πŸ’…


πŸ¦‹ Specializations πŸ¦‹

The standard library provides a specialization of std::bit_or when T is not specified, which leaves the parameter types and return type to be deduced. (since C++14)

  • bit_or<void> β€” function object implementing x | y deducing parameter and return types (C++14) β€” class template specialization. this one ate πŸ’–

πŸŽ€ Member types πŸŽ€

  • result_type β€” T β€” (deprecated in C++17)(removed in C++20)
  • first_argument_type β€” T β€” (deprecated in C++17)(removed in C++20)
  • second_argument_type β€” T β€” (deprecated in C++17)(removed in C++20)

The way that these member types are obtained is via publicly inheriting std::binary_function<T, T, T>. (until C++11) β€” lowkey historic, highkey important 🧚


πŸ’œ Member functions πŸ’œ

  • operator() β€” returns the result of bitwise OR of two arguments (public member function). obsessed with the clarity, ngl ✨

πŸ”₯ std::bit_or::operator() πŸ”₯

T operator()( const T& lhs, const T& rhs ) const;            (until C++14)
constexpr T operator()( const T& lhs, const T& rhs ) const;  (since C++14)

Returns the result of bitwise OR of lhs and rhs. that’s it, that’s the function, iconic behavior πŸ’…


πŸ“ Parameters πŸ“

  • lhs, rhs β€” values to compute bitwise OR of

🌈 Return value 🌈

The result of lhs | rhs. periodt πŸ’–


⭐ Exceptions ⭐

May throw implementation-defined exceptions. vibe check: yes, it can throw, no cap 😭


πŸ¦‹ Possible implementation πŸ¦‹

constexpr T operator()(const T& lhs, const T& rhs) const
{
    return lhs | rhs;
}

literally the blueprint, bestie β€” short, sweet, iconic πŸŽ€


πŸ‘‘ Defect reports πŸ‘‘

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: LWG 660 β€” Applied to: C++98 β€” Behavior as published: function objects for bitwise operations are missing β€” Correct behavior: added. fr fr, they fixed it 🌸

source/version: http://cppreference.com Β· date: 2024.06.10 Β· manual: std::bit_or(3) β€” okay bestie, that’s the cute sign-off, go forth and bitwise-OR responsibly πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from