std::array<T,N>:: rbegin, std::array<T,N>:: crbegin
From cppreference.net
|
reverse_iterator rbegin
(
)
noexcept
;
|
(1) |
(C++11부터)
(C++17부터 constexpr) |
|
const_reverse_iterator rbegin
(
)
const
noexcept
;
|
(2) |
(C++11부터)
(C++17부터 constexpr) |
|
const_reverse_iterator crbegin
(
)
const
noexcept
;
|
(3) |
(C++11부터)
(C++17부터 constexpr) |
역순으로 바뀐 * this 의 첫 번째 요소를 가리키는 역방향 반복자를 반환합니다. 이것은 역순으로 바뀌지 않은 * this 의 마지막 요소에 해당합니다.
만약 * this 가 비어있는 경우, 반환된 반복자는 rend() 와 같습니다.
목차 |
반환값
첫 번째 요소로의 역방향 반복자.
복잡도
상수.
참고 사항
반환된 역방향 반복자의 기반 반복자 는 end iterator 입니다. 따라서 end iterator가 무효화될 경우 반환된 반복자도 무효화됩니다.
예제
이 코드 실행
#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); }
출력:
Print “arr” in direct order using [cbegin, cend): ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ Print “arr” in reverse order using [crbegin, crend): █ ▇ ▆ ▅ ▄ ▃ ▂ ▁
참고 항목
|
역방향 반복자를 끝 위치로 반환
(public member function) |
|
|
(C++14)
|
컨테이너나 배열의 시작 위치로 역방향 반복자를 반환
(function template) |