Quantcast
Channel: イグトランスの頭の中
Viewing all articles
Browse latest Browse all 123

VC++でstd::get_timeがなんかダメ

$
0
0

Visual C++ 2015と2017 RCで、以下のプログラムが期待どおりに動きませんでした。

#include 
#include 
#include 
#include 

int main()
{
  std::istringstream s("20170110");

  std::tm x = {};
  s >> std::get_time(&x, "%Y%m%d");

  char buf[255];
  strftime(buf, sizeof(buf), "%Y-%m-%d", &x);
  std::cout << buf << std::endl;
}

%Yで2017だけパースされることを期待しているのですが、Visual C++の実装では、20170110まで読み込んでしまうようになっていました。

libstdc++やlibc++では、ちゃんと2017だけ読み込む実装だったので、Visual C++のほうに問題がありそうです。

VC++でstd::get_timeがなんかダメ is a post from: イグトランスの頭の中


Viewing all articles
Browse latest Browse all 123

Latest Images

Trending Articles