namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


Action disabled: source
kennen:lib:all_of

all_of()

#include <algorithm>

bool all_of (In first, In last, Pred pred) 
bool all_of (Exec pol, In first, In last, Pred pred) 
 
bool ranges::all_of(Range r, Pred pred, Proj proj = {})
bool ranges::all_of(In first, In last, Pred pred, Proj proj = {})

Prüft, ob alle Elemente e des Bereiches [first,last) das Prädikat pred(proj(e)) erfüllen. Bei leerem Bereich liefert die Funktion true.

Parameter

first Anfang des Bereiches
last Ende des Bereiches
pred einstelliges Prädikat
proj einstelliger Funktor (Vorgabe = std::identity)
pol parallele Ausführungsart

Ergebnis

Rückgabewert: false beim ersten Iterator i mit pred(proj(*i)) == false, Wurde kein Element gefunden, wird true geliefert.

Siehe auch

Beispiel

all_of.cpp
#include <algorithm>
#include <iostream>
 
bool ist_vokal(char c)
{
  return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
 
int main()
{
  const char str[] = "Hallo Welt";
  std::cout << std::all_of(str, str+10, ist_vokal);
}
kennen/lib/all_of.txt · Zuletzt geändert: 2020-06-14 12:46 von 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki