我有一个变量long
存储为std::chrono::system_clock::time_point.time_since_epoch().count()
的值。
我现在想从std::chrono::system_clock::time_point
变量中恢复该long
。
那么如何将long
转换为std::chrono::system_clock::time_point
?
答案 0 :(得分:2)
您首先需要将整数类型转换为select week, count(*) as weekcount,
sum(ispass) as passcount,
sum(isfail) as failcount,
(sum(ispass) + sum(isfail)) as passfailcount
from table1 t1 cross apply
(values (case when result = 'pass' then 1 else 0 end,
case when result = 'fail' then 1 else 0 end
)
) v(ispass, isfail)
group by week
order by week
,然后将chrono::duration
转换为duration
。但是有一个陷阱:
system_clock::time_point
是模板:
duration
如果将整数类型转换为错误 template <class Rep, class Period> class duration;
,则会得到错误的duration
。
幸运的是,time_point
本身会告诉您正确的system_clock
及其嵌套的duration
类型:duration
。此外,这些转换都是system_clock::duration
。
因此,总而言之:
explicit