Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 638 Bytes

minmax.md

File metadata and controls

21 lines (16 loc) · 638 Bytes

minmax

Description : Compares values returning a pair of [smallest, greatest]. Can be used for values or containers.

Example:

    int a = 7, b = 3;
    
    // returns pair <3, 7>
    auto minMax1 = std::minmax(a, b);
    std::cout << "Min is " << minMax1.first <<
                 " Max is " << minMax1.second << std::endl;

    // returns pair <-1, 10>
    auto minMax2 = std::minmax({-1, 3, 10, 0});
    std::cout << "Min is " << minMax2.first <<
                 " Max is " << minMax2.second << std::endl;

See Sample code Run Code