0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VC++(Windows)で std::chrono の min,max が使えない

Posted at

(std::min()とかで明示してもダメ)
どうやら、minmaxWindows.h で 関数定義ではなく #defineで定義されているのが諸悪の根源っぽいです・・・。

回避するには以下

sample.cpp
using namespace std;

# undef max
# undef min
				// ここで min(), max() を使う
				// 念のためここでは、Windows関係の関数を実行しないこと
# ifndef max
# define max(a,b)            (((a) > (b)) ? (a) : (b))
# endif
# ifndef min
# define min(a,b)            (((a) < (b)) ? (a) : (b))
# endif

ベタですが、Windows.hによって定義されているmin,maxを一旦定義解除して、やりたい事が終わったら再定義する感じです。

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?