Inhaltsverzeichnis

min()

#include <algorithm>

const T& min (const T& a, const T& b) 
const T& min (const T& a, const T& b, Binary comp)
T min(std::initializer_list<T> values)  
T min(std::initializer_list<T> values, Binary comp)  
 
const T& ranges::min (const T& a, const T& b, Binary comp = {}, Proj proj = {})
T ranges::min (std::initializer_list<T> values, Binary comp = {}, Proj proj = {})
T ranges::min (Range r, Binary comp = {}, Proj proj = {})

Liefert den kleinsten Wert.

Parameter

a Wert
b Wert
comp Sortierkriterium (Vorgabe = less)
proj einstelliger Funktor (Vorgabe = std::identity)

Ergebnis

Rückgabewert: b, wenn b < a bzw. comp(proj(b),proj(a)) != false, sonst a.

Siehe auch

max(), minmax().

Beispiel

min.cpp
#include <algorithm>
#include <iostream>
 
int main()
{
  int x, y;
  std::cout << "Gib zwei Zahlen ein: ";
  std::cin >> x >> y;
 
  std::cout << std::min(x,y) << " <= " << std::max(x,y) << '\n';
}