- 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
- Clang: 5.0 [mark verified]
- GCC: 7.1 [mark verified]
- Visual C++: ??