#include
<algorithm>
bool is_sorted (For first, For last) bool is_sorted (For first, For last, Binary comp) bool is_sorted (Exec pol, For first, For last) bool is_sorted (Exec pol, For first, For last, Binary comp) bool ranges::is_sorted (Range r, Binary comp = {}, Proj proj = {}) bool ranges::is_sorted (For first, For last, Binary comp = {}, Proj proj = {})
Prüft, ob der Bereich [first,last) in aufsteigender Folge sortiert ist.
first | Anfang des Bereiches |
last | Ende des Bereiches |
comp | Vergleichskriterium (Vorgabe = less ) |
proj | einstelliger Funktor (Vorgabe = std::identity ) |
pol | parallele Ausführungsart |
Rückgabewert: true
, falls der Bereich aufsteigend sortiert ist.
#include <algorithm> #include <iostream> #include <string> int main() { std::string s = "Hallo, Welt"; std::cout << s << " : " << std::is_sorted(begin(s), end(s)) << '\n'; }