std::advance

Da cppreference.com.
< cpp‎ | iterator

 
 
Biblioteca Iterator
Primitive iteratori
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
Adattatori iteratori
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
Flusso iteratori
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
Operazioni di iteratori
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)
Intervallo accesso
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)
 
Elemento definito nell'header <iterator>
template<class InputIt, class Distance >
void advance( InputIt& it, Distance n );
Incrementa dato iteratore it dal n elementi.
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.
Se n è negativo, l'iteratore viene decrementato. In questo caso, InputIt deve soddisfare i requisiti di BidirectionalIterator, altrimenti il ​​comportamento è indefinito.
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.

Indice

[modifica]Parametri

it -
iteratore da anticipare
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 -
numero di elementi it dovrebbe essere avanzato
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.

[modifica]Valore di ritorno

(Nessuno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Complessità

Lineare.
Original:
Linear.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tuttavia, se InputIt soddisfa inoltre i requisiti di RandomAccessIterator, complessità è costante.
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.

[modifica]Esempio

#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

[modifica]Vedi anche

restituisce la distanza tra due iteratori
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.

(funzione)[modifica]
close