我有一个时间戳(自纪元以来的纳秒数):
uint64_t ts = .....;
我想检查它是否比当前系统时间早超过5秒。
因此,我需要将时间戳转换为一个time_point
,然后从当前时间(以纳秒为单位)中减去它的值,并检查其值是否大于chrono::duration::seconds(5)
?
目前已经完成以下内容:
const std::chrono::time_point tstp(std::chrono::duration_cast<std::chrono::nanoseconds>(rawNanos));
const std::chrono::time_point now = std::chrono::high_resolution_clock::now();
const bool old = now - tstp > std::chrono::seconds(5);
但是由于time_point的构造器类型而感到困扰。