Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.22 KB

op_left_shift.md

File metadata and controls

63 lines (45 loc) · 1.22 KB

operator<<

  • cstddef[meta header]
  • std[meta namespace]
  • function template[meta id-type]
  • cpp17[meta cpp]
namespace std {
  template <class IntType>
  constexpr byte operator<<(byte b, IntType shift) noexcept;
}

概要

byte型の値を左ビットシフトする。

要件

  • IntTypeは、std::is_integral_v<IntType> == trueであること。そうでない場合、この関数はオーバーロード解決の候補から除外される

効果

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

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

例外

投げない

#include <cassert>
#include <cstddef>

int main()
{
  std::byte b{0b0000'0001};
  std::byte result = b << 3;

  assert(static_cast<unsigned char>(result) == 0b0000'1000);
}

出力

バージョン

言語

  • C++17

処理系

参照