std::put_time implementation status in GCC?(GCC 中的 std::put_time 实现状态?)
问题描述
我试图使用 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_time 或 chrono 或类似的笔记.任何人都可以向我指出提供有关此库实施状态信息的资源吗?
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_time 和 std::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 让我知道.
这篇关于GCC 中的 std::put_time 实现状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:GCC 中的 std::put_time 实现状态?
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
