Use of min () and Max () functions in Visual C + + __jquery

Source: Internet
Author: User

The standard library defines two template functions Std::min () and Std::max () in the <algorithm> header. It is usually 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 conflict with the traditional Min/max macro definition in <windows.h>. To address 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 add the following before including the <windows.h> header file:

 

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, enter the menu "project" => "Settings" (Open the Settings dialog) => the "Setting for" in the upper left corner Select "All Configurations" in the Drop-down list box, and then select the "C + +" tab => Add "Nominmax" to the preprocessor difinitions edit box.

Visual C + + 7.0: Open the project file (*.sln) or (*.vcproj), select the project to define, enter the menu "project" => "Properties" (Open Project Properties dialog box) => in the upper-left corner of the configuration drop-down list box, select all configurations. Then, in the property configuration on the left, select the => "C + +" => "preprocessor" => right "preprocessor definition" to add "Nominmax".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.