The standard library defines two template functions in the <algorithm> header: STD: min () and STD: max (). It is usually used to calculate the minimum and maximum values of a value pair.
Unfortunately, they cannot be used in Visual C ++ because these function templates are not defined. The reason is that the name Min and Max conflict with the traditional min/MAX macro definition in <windows. h>. To solve this problem, Visual C ++ defines two templates with the same functions: _ cpp_min () and _ cpp_max (). We can use them to replace STD: min () and STD: max ().
To disable the min/MAX macro definition in Visual C ++, you can add:
# Define nominmax
Or add nominmax to Preprocessor difinitions. The specific method is:
Visual c ++ 6.0: Open the project file (*. DSW) or (*. DSP), select the project to be defined, and go to the menu "project" => "Settings" (open the Settings dialog box) => in the "setting for" drop-down list box in the upper left corner, select "all deployments ", then select the "C/C ++" label => Add "nominmax" to the "Preprocessor difinitions" edit box.
Visual c ++ 7.0: Open the project file (*. SLN) or (*. vcproj), select the project to be defined, and go to the menu "project" => "properties" (open the Project Properties dialog box) => in the "configuration" drop-down list box in the upper left corner, select "All configurations ", then, select "C/C ++"> "pre-processor"> "pre-processor definition" on the left and add "nominmax ".