std::advance
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
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.
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.
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 avanzatoOriginal: 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 . |
[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.
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.
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.
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) |