2013-01-03 75 views
52

我试图编译使用GCC this example program(测试版本4.5.1,4.6.3,4.8.4):std :: put_time在GCC中的实现状态?

#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'; 
} 

But it tells me:

prog.cpp: In function 'int main()': 
prog.cpp:14:18: error: 'put_time' is not a member of 'std' 

我想,也许这不是尚未实施。所以我试图检查这个函数的实现状态。我只找到了这个网页:

但我找不到任何音符put_timechrono或相似。任何人都可以指向一个资源,提供关于这个库的实现状态的信息吗?

回答

68

查看TODO extended iomanip manipulators std::get_time and std::put_time对于gcc 4.8.0。

另请参见Cross Platform way to get the time of day?声称未在4.7.0中实施。


UPDATE:如下gcc的开发者Jonathan Wakely confirmed:本std::get_timestd::put_time操纵中还没有GCC 4.9。


UPDATE:乔纳森Wakely closed这张票上2014年12月22日:

修正了GCC 5

感谢simonwo让我知道。

+2

GCC 4.9已经发布 - 看起来它不在那里,不是吗? – ollo

+4

@ollo As [Jonathan has confirmed](http://stackoverflow.com/questions/14136833/stdput-time-implementation-status-in-gcc/14137287?noredirect=1#comment35569824_14142342),gcc 4.9仍然缺乏这些功能。 :(是的,那很伤心 – Ali

+0

是的,我刚刚检查了4.9源码,无论如何,谢谢。 – ollo

17

您可能已经注意到您提供的链接没有列出任何部分库!但是,下面的表格,它说:

的库实现的状态可以在此table

该表指出,std::get_timestd::put_time操纵尚未落实进行跟踪。

编辑:put_time现在在GCC开发中心。

+4

直接从开发商:) – Ali