Namensräume
Varianten
Aktionen

std::advance

Aus cppreference.com
< cpp‎ | iterator

 
 
Iterator Bibliothek
Iterator Primitiven
Original:
Iterator primitives
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iterator_traits
input_iterator_tag
output_iterator_tag
forward_iterator_tag
bidirectional_iterator_tag
random_access_iterator_tag
iterator
Iterator Adaptern
Original:
Iterator adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
reverse_iterator
Stream-Iteratoren
Original:
Stream iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istream_iterator
ostream_iterator
istreambuf_iterator
ostreambuf_iterator
Iterator Operationen
Original:
Iterator operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
advance
distance
prev(C++11)
next(C++11)
Reichen Zugang
Original:
Range access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
begin(C++11)
end(C++11)
 
Defined 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.
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.

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 werden
Original:
number of elements it should be advanced
The 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.

[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.
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.

[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) [edit]