문제

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