255, the stored v-6ren">
gpt4 book ai didi

c++ - 如果 d > 255,为什么未指定 std::chrono::day 存储值

转载 作者:行者123 更新时间:2023-12-04 02:29:48 25 4
gpt4 key购买 nike

引自std::literals::chrono_literals::operator""d

A std::chrono::day storing d. If d > 255, the stored value is unspecified.

此限制背后的基本原理是什么?

最佳答案

文字不能存储超过std::chrono::day本身可以,也就是0-255。这允许它作为 1 字节数据类型实现,因为它通常只存储 1 到 31 之间的值就足够了。

如果您正在寻找一种数据类型来存储任意天数的持续时间,请使用 std::chrono::days相反。

关于c++ - 如果 d > 255,为什么未指定 std::chrono::day 存储值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64968354/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com