namespace cpp {}

C++ lernen, kennen, anwenden

Benutzer-Werkzeuge

Webseiten-Werkzeuge


kennen:lib:for_each

Dies ist eine alte Version des Dokuments!


for_each()

#include <algorithm>

Function for_each (In first, In last, Function f) 
Function for_each (Exec pol, In first, In last, Function f) 
 
[last, f] = ranges::for_each(Range r, Function f, Proj proj = {})
[last, f] = ranges::for_each(In first, In last, Function f, Proj proj = {})

Wendet f(proj(e)) auf jedes Element e des Bereiches [first,last) an.

Parameter

first Anfang des Bereiches
last Ende des Bereiches
f einstellige Funktion oder Funktor
proj einstelliger Funktor (Vorgabe = std::identity)
pol parallele Ausführungsart

Ergebnis

Rückgabewert: die Funktion bzw. das (möglicherweise veränderte) Funktionsobjekt f.
bzw.
Struktur mit Elementen {in, fun}

Siehe auch

Beispiel

for_each.cpp
#include <algorithm>
#include <iostream>
 
int main()
{
  int arr[] = { 1, 2, 3, 4, 5 };
  std::for_each(arr, ar+5), [](int x) { std::cout << x << ' '; });
}
kennen/lib/for_each.1697275506.txt.gz · Zuletzt geändert: 2023-10-14 11:25 von rrichter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki