std::array<T,N>:: rbegin, std::array<T,N>:: crbegin
|
reverse_iterator rbegin
(
)
noexcept
;
|
(1) |
(desde C++11)
(constexpr desde C++17) |
|
const_reverse_iterator rbegin
(
)
const
noexcept
;
|
(2) |
(desde C++11)
(constexpr desde C++17) |
|
const_reverse_iterator crbegin
(
)
const
noexcept
;
|
(3) |
(desde C++11)
(constexpr desde C++17) |
Devuelve un iterador inverso al primer elemento del * this invertido. Corresponde al último elemento del * this no invertido.
Si * this está vacío, el iterador devuelto es igual a rend() .
Contenidos |
Valor de retorno
Iterador inverso al primer elemento.
Complejidad
Constante.
Notas
El iterador subyacente del iterador inverso devuelto es el iterador final . Por lo tanto, el iterador devuelto se invalida si y cuando el iterador final se invalida.
Ejemplo
#include <algorithm> #include <array> #include <iostream> #include <string> #include <string_view> void print(const std::string_view s) { std::cout << s << ' '; } int main() { const std::array<std::string_view, 8> data { "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }; std::array<std::string, 8> arr; std::copy(data.cbegin(), data.cend(), arr.begin()); print("Print “arr” in direct order using [cbegin, cend):\t"); std::for_each(arr.cbegin(), arr.cend(), print); print("\n\nPrint “arr” in reverse order using [crbegin, crend):\t"); std::for_each(arr.crbegin(), arr.crend(), print); }
Salida:
Print “arr” in direct order using [cbegin, cend): ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ Print “arr” in reverse order using [crbegin, crend): █ ▇ ▆ ▅ ▄ ▃ ▂ ▁
Véase también
|
devuelve un iterador inverso al final
(función miembro pública) |
|
|
(C++14)
|
devuelve un iterador inverso al inicio de un contenedor o array
(plantilla de función) |