定义于头文件
<cstddef>
|
||
enum class byte : unsigned char {} ;
|
(C++17 起) | |
std::byte
是一种独立类型,它实现指定于 C++ 语言定义中的字节的概念。
同 char 与 unsigned char ,它能用于访问其他对象所占据的生内存(对象表示),但不同于这些类型,它不是字符类型且非算术类型。一个 byte 只是位的汇集,且只有逐位逻辑运算符对它有定义。
目录 |
template <class IntegerType>
constexpr IntegerType to_integer(std::byte b) noexcept; |
(C++17 起) | |
等价于: return IntegerType(b); 此重载仅若 std::is_integral_v<IntegerType> 为 true 才参与重载决议。
template <class IntegerType>
constexpr std::byte& operator<<=(std::byte& b, IntegerType shift) noexcept; |
(1) | (C++17 起) |
template <class IntegerType>
constexpr std::byte& operator>>=(std::byte& b, IntegerType shift) noexcept; |
(2) | (C++17 起) |
template <class IntegerType>
constexpr std::byte operator <<(std::byte b, IntegerType shift) noexcept; |
(1) | (C++17 起) |
template <class IntegerType>
constexpr std::byte operator >>(std::byte b, IntegerType shift) noexcept; |
(2) | (C++17 起) |
此重载仅若 std::is_integral_v<IntegerType> 为 true 才参与重载决议。
constexpr std::byte& operator|=(std::byte& l, std::byte r) noexcept;
|
(1) | (C++17 起) |
constexpr std::byte& operator&=(std::byte& l, std::byte r) noexcept;
|
(2) | (C++17 起) |
constexpr std::byte& operator^=(std::byte& l, std::byte r) noexcept;
|
(3) | (C++17 起) |
constexpr std::byte operator|(std::byte l, std::byte r) noexcept;
|
(1) | (C++17 起) |
constexpr std::byte operator&(std::byte l, std::byte r) noexcept;
|
(2) | (C++17 起) |
constexpr std::byte operator^(std::byte l, std::byte r) noexcept;
|
(3) | (C++17 起) |
constexpr std::byte operator~(std::byte b) noexcept;
|
(4) | (C++17 起) |
由于 C++17 放松的 enum class 初始化规则,数值 n
能用 std::byte{n
} 转换成 byte 值。
byte 能用 std::to_integer 转换成数值(例如生成对象的整数哈希)。
本节未完成 原因:暂无示例 |