【发布时间】:2021-06-10 02:06:20
【问题描述】:
我有一个
typedef std::array<std::byte, 4> CatType;
我想初始化一个这种类型的常量。我可以的
const CatType mycat = {std::byte{0x00}, std::byte{0x00}, std::byte{0x00}, std::byte{0x00}};
这很有效,但我想要类似的可读性
const CatType mycat = 0x001020ff
失败并出现错误
conversion from ‘int’ to non-scalar type ‘const CatType’ {aka ‘const std::array<std::byte, 4>’} requested
【问题讨论】: