• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <cstddef>

    std::operator|

    namespace std {
      constexpr byte operator|(byte l, byte r) noexcept;
    }
    

    概要

    byte型の値をビット論理和する。

    効果

    以下の式と等価の効果をもつ:

    return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(l) | static_cast<unsigned int>(r)));
    

    例外

    投げない

    #include <cassert>
    #include <cstddef>
    
    int main()
    {
      std::byte a{0b0000'0011};
      std::byte b{0b0000'0101};
    
      std::byte result = a | b;
    
      assert(static_cast<unsigned char>(result) == 0b0000'0111);
    }
    

    出力

    バージョン

    言語

    • C++17

    処理系

    参照