首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::chrono::round(std::chrono::duration)

Defined in header <chrono>

?

?

template <class ToDuration, class Rep, class Period> constexpr ToDuration round(const duration<Rep, Period>& d);

?

(since C++17)

返回值t可在ToDuration这是最接近d如果有两个这样的值,则返回偶数%28,即值t使...t % 2 == 029%。

该函数不参与重载解析,除非ToDurationstd::chrono::durationstd::chrono::treat_as_floating_point<typename ToDuration::rep>::valuefalse...

参数

d

-

duration to convert

返回值

d四舍五入至最接近类型的持续时间ToDuration甚至在半途而废的情况下。

可能的实施

模板<class T>结构是[医]持续时间:STD::false[医]类型{};模板<类Rep,类周期>结构是[医]持续时间<std::time::time<rep,time>>:std::true[医]类型{};模板<class到类,类Rep,类周期,class=std::Enable[医]如果[医]T<IS[医]持续时间<To>{}&%21 std::rono::[医]如[医]浮[医]点<typename To::rep>{}>>Conexpr to整数%28 const std::chrono::time<rep,期>&d%29{to 0=std::chrono::time:<To>%28d%29;to t1=t0+to{1};自动扩散0=d-t0;自扩散1=t1-d;if%28Diff0==dc 1%29{if%28t0.计数%28%29和1%29返回T1;返回t0;

*。

另见

duration_cast

converts a duration to another, with a different tick interval (function template)

floor(std::chrono::duration) (C++17)

converts a duration to another, rounding down (function template)

ceil(std::chrono::duration) (C++17)

converts a duration to another, rounding up (function template)

round(std::chrono::time_point) (C++17)

converts a time_point to another, rounding to nearest, ties to even (function template)

roundlroundllround (C++11)(C++11)(C++11)

nearest integer, rounding away from zero in halfway cases (function)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com