Espacios de nombres
Variantes
Acciones

std::advance

De cppreference.com
< cpp‎ | iterator

 
 
Biblioteca Iterator
Primitivas iterador
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.
Adaptadores iterador
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.
Iteradores Stream
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.
Operaciones iterador
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
(C++11)
(C++11)
Rango de acceso
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.
(C++11)
(C++11)
 
Definido en la cabecera <iterator>
template< class InputIt, class Distance >
void advance( InputIt& it, Distance n );
Incrementos dado iterador it por n elementos .
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.
Si n es negativo, el iterador se decrementa. En este caso, InputIt debe cumplir los requisitos de BidirectionalIterator, de lo contrario el comportamiento es indefinido .
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.

Contenido

[editar] Parámetros

it -
iterador para ser avanzada
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 -
número de it elementos deben ser avanzada
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.
Requerimientos de tipo
-
InputIt debe reunir los requerimientos de InputIterator.

[editar] Valor de retorno

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

[editar] Complejidad

Lineal .
Original:
Linear.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sin embargo, si InputIt además cumple con los requisitos de RandomAccessIterator, la complejidad es 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.

[editar] Ejemplo

#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';
}

Salida:

4

[editar] Ver también

devuelve la distancia entre dos iteradores
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.

(función) [editar]