0

Which _STD function(s) return the max, or min of 2 integers, signed or unsigned? Is it the max, min in the math.h header library or what could they be?

Radiodef
  • 37,180
  • 14
  • 90
  • 125
user3267146
  • 317
  • 2
  • 10
  • Possible duplicate of [Use of min and max functions in C++](https://stackoverflow.com/questions/1632145/use-of-min-and-max-functions-in-c) – Radiodef Jun 28 '18 at 21:09

3 Answers3

2

std::min and std::max in the <algorithm> library. As they're templates they return the min and max for every type that implements the < operator (or you can supply a functor for your custom comparison).

See Algorithms library (link to cppreference.com).

jpw
  • 44,361
  • 6
  • 66
  • 86
2

You can use the new algorithm introduced in C++11(

 template<class T> pair<const T&, const T&> minmax(const T& a, const T& b);

Returns: pair(b, a) if b is smaller than a, and pair(a, b) otherwise.

Mantosh Kumar
  • 5,659
  • 3
  • 24
  • 48
1

std::max and std::min are in the file algorithm.

You can look up the other functions included in this file at C++ Reference. Bookmark it for future usage.

R Sahu
  • 204,454
  • 14
  • 159
  • 270