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?
Asked
Active
Viewed 8,246 times
3 Answers
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