Inhaltsverzeichnis

lower_bound()

#include <algorithm>

For lower_bound (For first, For last, T wert) 
For lower_bound (For first, For last, T wert, Binary comp) 
 
For ranges::lower_bound (Range r, T wert, Binary comp = {}, Proj proj = {}) 
For ranges::lower_bound (For first, For last, T wert, Binary comp = {}, Proj proj = {}) 

Bestimmt die erste Position, an der wert eingefügt werden kann, ohne die aufsteigende Ordnung der Folge [first,last) zu zerstören.

Parameter

first Anfang des Bereiches
last Ende des Bereiches
wert gesuchter Wert
comp Sortierkriterium (Vorgabe = less)
proj einstelliger Funktor (Vorgabe = std::identity)

Ergebnis

Rückgabewert: linke Grenze i des Teilbereiches, in dem wert eingefügt werden kann, ohne die Sortierung zu zerstören. Für alle Iteratoren j aus [first, i) gilt:

 comp(proj(*j), wert) == true

Siehe auch

equal_range(), upper_bound().

Beispiel

lower_bound.cpp
#include <algorithm>
#include <iostream>
#include <string>
 
int main()
{
  std::string s = "abcddddefgh";
 
  std::cout << s << '\n'
            << "   "    << lower_bound(begin(s), end(s), 'd') << '\n';
            << "   ^^^" << upper_bound(begin(s), end(s), 'd') << '\n';
}