How would I go about actually calling std::max? The code won't compile in visual studio 2013, because it takes "max" as the macro.

std::max( ... );

Expects an identifier after the "std::".

有帮助吗?

解决方案

You can undefine the macro:

#undef max

Edit: It seems the macros can be safely disabled by putting

#define NOMINMAX

before the header files that define them (most likely windef.h, which you probably include indirectly).

To avoid undefining the macro, you can simply wrap the function in parenthesis

(std::max)(...)

As noted by chris in the comments, function-like macros require the token after the macro name to be a left parenthesis in order to expand. Wrapping the name in parentheses is really just a hack to make the next token a right parenthesis without changing the meaning once you put macros aside.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top