2013-01-03 73 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