![](/img/trans.png)
[英]Converting string representation of last modification time back to its type(std::filesystem::file_time_type)
[英]Why time_since_epoch() from a std::filesystem::file_time_type is negative?
為什么下面的代碼 output 是負數?
coliru 鏈接可以自己查看和編譯代碼。
#include <chrono>
#include <filesystem>
#include <iostream>
int main()
{
std::cout << "Now: "
<< std::filesystem::file_time_type::clock().now().time_since_epoch().count()
<< "\n";
return 0;
}
Output:
Now: -4818978774392359625
libstdc++ 的std::filesystem::file_time_type::clock()
的紀元似乎是2174-01-01 00:00:00 UTC ,因此當前日期的負數並不意外。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.