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

履歴 編集

function
<cstddef>

std::operator~(C++17)

namespace std {
  constexpr byte operator~(byte b) noexcept;
}

概要

byte型の値をビット反転する。

効果

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

return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(b)));

例外

投げない

#include <cassert>
#include <cstddef>
#include <climits>

int main()
{
  static_assert(CHAR_BIT == 8);

  std::byte x{0b0000'0011};
  std::byte result = ~x;

  assert(static_cast<unsigned char>(result) == 0b1111'1100);
}

出力

バージョン

言語

  • C++17

処理系

参照