C++ GCC 中的 std::put_time 实现状态?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14136833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
std::put_time implementation status in GCC?
提问by moooeeeep
I was trying to compile this example programusing GCC (tested versions 4.5.1, 4.6.3, 4.8.4):
我试图使用 GCC(测试版本 4.5.1、4.6.3、4.8.4)编译这个示例程序:
#include <iostream>
#include <iomanip>
#include <ctime>
#include <chrono>
using std::chrono::system_clock;
int main()
{
system_clock::time_point now = system_clock::now();
std::time_t now_c = system_clock::to_time_t(
now - std::chrono::hours(24));
std::cout << "One day ago, the time was "
<< std::put_time(std::localtime(&now_c), "%F %T") << '\n';
}
prog.cpp: In function 'int main()':
prog.cpp:14:18: error: 'put_time' is not a member of 'std'
I thought, probably it's not implemented yet. So I tried to check the implementation status for this function. I only found this page:
我想,可能它还没有实施。所以我试图检查这个函数的实现状态。我只找到了这个页面:
but there I could not find any note on put_time
or chrono
or alike. Can anyone point me to a resource that provides information on the implementation status for this library?
但我找不到任何音符上put_time
或chrono
或相似。任何人都可以指向我提供有关此库实施状态信息的资源吗?
回答by Ali
See TODO extended iomanip manipulators std::get_time and std::put_timefor gcc 4.8.0.
请参阅gcc 4.8.0 的TODO 扩展 iomanip 操纵器 std::get_time 和 std::put_time。
See also Cross Platform way to get the time of day?claiming that is not implemented in 4.7.0.
另请参阅获取时间的跨平台方式?声称在 4.7.0 中没有实现。
UPDATE:As the gcc developer Jonathan Wakely confirmedbelow: The std::get_time
and std::put_time
manipulators are still missing in gcc 4.9.
更新:正如 gcc 开发人员Jonathan Wakely在下面确认的那样:gcc 4.9 中仍然缺少std::get_time
和std::put_time
操纵器。
UPDATE:Jonathan Wakely closedthis ticket on 22 Dec, 2014:
更新:Jonathan Wakely在 2014 年 12 月 22 日关闭了这张票:
Fixed for GCC 5
修复了 GCC 5
Thanks simonwofor letting me know about it.
感谢simonwo让我知道这件事。
回答by Jonathan Wakely
You might have noticed the link you gave doesn't list anyparts of the library! But below the table it says:
您可能已经注意到您提供的链接没有列出库的任何部分!但在桌子下面它说:
The status of the library implementation can be tracked in this table
可以在此表中跟踪库实现的状态
That table notes that std::get_time
and std::put_time
manipulators are not implemented yet.
该表指出std::get_time
和std::put_time
操纵器尚未实现。
Edit: put_time
is now on the GCC development trunk.
编辑:put_time
现在在 GCC 开发主干上。