GCC中的std :: put_time实施状态?

moo*_*eep 63 c++ gcc std c++11 c++-chrono

我试图使用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';
}
Run Code Online (Sandbox Code Playgroud)

但它告诉我:

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

我想,可能还没有实现.所以我试着检查这个功能的实现状态.我只找到了这个页面:

但我找不到任何笔记put_timechrono或相似.任何人都可以指向我提供有关此库的实现状态的信息的资源吗?

Ali*_*Ali 76

有关gcc 4.8.0的信息,请参阅TODO扩展iomanip操纵器std :: get_time和std :: put_time.

另请参阅Cross Platform获取时间的方法?声称没有在4.7.0中实现.


更新:正如gcc开发人员Jonathan Wakely在下面所证实的那样:gcc 4.9中仍然缺少操纵器std::get_timestd::put_time操纵器.


更新: Jonathan Wakely 2014年12月22日关闭此门票:

适用于GCC 5

谢谢simonwo让我知道它.

  • @ollo正如[Jonathan已确认](http://stackoverflow.com/questions/14136833/stdput-time-implementation-status-in-gcc/14137287?noredirect=1#comment35569824_14142342),gcc 4.9仍然缺乏这些功能.:(是的,那很难过. (6认同)
  • GCC 4.9已经发布 - 似乎它既不在那里,不是吗? (2认同)

Jon*_*ely 19

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

可以在此表中跟踪库实现的状态

该表注意到std::get_time并且std::put_time操纵器尚未实现.

编辑:put_time现在是GCC开发主干.

  • 直接从开发者:) (4认同)