The standard library defines two template functions Std::min () and Std::max () in the <algorithm> header. It is commonly used to calculate the minimum and maximum values for a pair of values.
Unfortunately, they are not available in Visual C + + because these function templates are not defined. The reason is that the name min and Max are in conflict with the traditional Min/max macro definition in <windows.h>. To solve this problem, Visual C + + defines two other templates with the same functionality: _cpp_min () and _cpp_max (). We can use them instead of std::min () and Std::max ().
In order to disable the Min/max macro definition in Visual C + +, you can include the <windows.h> header file by adding:
Or add Nominmax to the preprocessor difinitions. The specific methods are:
Visual C + + 6.0: Open a project file (*.DSW) or (*.DSP), select the project you want to define, go to the menu "project" and "Settings" (Open Settings dialog box) and "Setting for" in the upper left corner Drop-down list box, select "All Configurations", and then select the "C + +" tab and "Add Nominmax" to the "Preprocessor difinitions" edit box.
Visual C + + 7.0: Open the Project document (*.sln) or (*.vcproj), select the project to be defined, go to the menu "project" and "Properties" (Open Project Properties dialog box) and select "All Configurations" at the top left of the "Configuration" drop-down list box. Then in the left "property configuration", select "+/C + +" and "preprocessor" +-right "preprocessor definition" plus "Nominmax".