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

2021-12-18 00:00:00 gcc c++ c++11 chrono std

我试图使用 GCC(测试版本 4.5.1、4.6.3、4.8.4):

I was trying to compile this example program using GCC (tested versions 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") << '
';
}

但它告诉我:

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:

  • http://gcc.gnu.org/projects/cxx0x.html

但在那里我找不到任何关于 put_timechrono 或类似的笔记.任何人都可以向我指出提供有关此库实施状态信息的资源吗?

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?

推荐答案

参见 TODO用于 gcc 4.8.0 的扩展 iomanip 操纵器 std::get_time 和 std::put_time.

另请参阅获取时间的跨平台方式?声称在 4.7.0 中未实现.

See also Cross Platform way to get the time of day? claiming that is not implemented in 4.7.0.

更新: 作为 gcc 开发人员 Jonathan Wakely 确认如下:std::get_timestd::put_time 操纵器在 gcc 4.9 中仍然缺失.

UPDATE: As the gcc developer Jonathan Wakely confirmed below: The std::get_time and std::put_time manipulators are still missing in gcc 4.9.

更新:乔纳森・韦克利关闭 2014 年 12 月 22 日的这张票:

UPDATE: Jonathan Wakely closed this ticket on 22 Dec, 2014:

已针对 GCC 5 修复

Fixed for GCC 5

感谢 simonwo 让我知道.

相关文章