std::advance
De 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. |
| Déclaré dans l'en-tête <iterator>
|
||
| template< class InputIt, class Distance > void advance( InputIt& it, Distance n ); |
||
Incréments donné itérateur
it par n éléments .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.
Si
n est négatif, l'itérateur est décrémenté. Dans ce cas, InputIt doit satisfaire aux exigences de BidirectionalIterator, sinon le comportement est indéfini .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.
Sommaire |
[modifier] Paramètres
| it | - | itérateur d'être avancé
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 | - | nombre de
it éléments devraient être favoriséesOriginal: 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.
| ||
[modifier] Retourne la valeur
(Aucun)
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.
[modifier] Complexité
Linéaire .
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.
Toutefois, si
InputIt répond en outre aux exigences de RandomAccessIterator, la complexité est constante .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.
[modifier] Exemple
#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'; }
Résultat :
4
[modifier] Voir aussi
| renvoie la distance entre deux itérateurs 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. (fonction) | |

