std::advance
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
definiert in Header <iterator>
|
||
template< class InputIt, class Distance > void advance( InputIt& it, Distance n ); |
||
Schritten angegeben Iterator
it
durch n
Elementen .Original:
Increments given iterator
it
by n
elements.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Wenn
n
negativ ist, wird der Iterator dekrementiert. In diesem Fall InputIt
müssen den Anforderungen der BidirectionalIterator
gerecht zu werden, da sonst das Verhalten undefiniert ist .Original:
If
n
is negative, the iterator is decremented. In this case, InputIt
must meet the requirements of BidirectionalIterator
, otherwise the behavior is undefined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inhaltsverzeichnis |
[Bearbeiten] Parameter
it | - | iterator vorangetrieben werden
Original: iterator to be advanced The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
n | - | Anzahl der Elemente
it sollte vorangetrieben werdenOriginal: number of elements it should be advancedThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Type requirements | ||
-InputIt must meet the requirements of InputIterator .
|
[Bearbeiten] Rückgabewert
(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Komplexität
Linear .
Original:
Linear.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Wenn jedoch zusätzlich
InputIt
erfüllt die Anforderungen der RandomAccessIterator
ist Komplexität konstanten .Original:
However, if
InputIt
additionally meets the requirements of RandomAccessIterator
, complexity is constant.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Beispiel
#include <iostream> #include <iterator> #include <vector> int main() { std::vector<int> v{ 3, 1, 4 }; auto vi = v.begin(); std::advance(vi, 2); std::cout << *vi << '\n'; }
Output:
4
[Bearbeiten] Siehe auch
gibt den Abstand zwischen zwei Iterationen Original: returns the distance between two iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktion) |