c++ - 如何在不同的 std::chrono 持续时间类型之间进行转换?

标签 c++ std c++-chrono

例如,如果我想从 std::chrono::nanoseconds 转换至std::chrono::seconds ,我该怎么做?

最佳答案

您正在寻找std::chrono::duration_cast :

auto seconds = std::chrono::duration_cast<std::chrono::seconds>(nanoseconds);

关于c++ - 如何在不同的 std::chrono 持续时间类型之间进行转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73521224/

相关文章:

c++ - 如何在 qt creator 中使用 clang 5 和 qt?

c++ - 在工厂模式中自动注册派生类

python - Pandas groupby agg std NaN

c - 将stdin流式传输到套接字

c++ - 使用C++标准库进行字符串混淆

c++ - 测量计算时间

c++ - Linux 定时器挂起信号

c++ - 有什么好的 C++ 项目构建工具可以替代 make 吗?

c++ - 如何在 Mac OSX 中获取真实的日历微秒时间(自 1970 年以来的纪元)?

c++ - 将 chrono::duration 类型转换为 std::tm 类型