Namespaces
Variants

std::span<T,Extent>:: rbegin, std::span<T,Extent>:: crbegin

From cppreference.net

constexpr reverse_iterator rbegin ( ) const noexcept ;
(1) (C++20부터)
constexpr const_reverse_iterator crbegin ( ) const noexcept ;
(2) (C++23부터)

역순으로 바뀐 * this 의 첫 번째 요소를 가리키는 역방향 반복자를 반환합니다. 이는 역순으로 바뀌지 않은 * this 의 마지막 요소에 해당합니다.

만약 * this 가 비어 있으면, 반환된 반복자는 rend() 와 같습니다.

range-rbegin-rend.svg

목차

반환값

첫 번째 요소로의 역방향 반복자.

복잡도

상수.

참고 사항

반환된 역방향 반복자의 기반 반복자 end 반복자 입니다. 따라서 end 반복자가 무효화될 때 반환된 반복자도 함께 무효화됩니다.

예제

#include <algorithm>
#include <iostream>
#include <iterator>
#include <span>
int main()
{
    constexpr std::span<const char> code{"@droNE_T0P_w$s@s#_SECRET_a,p^42!"};
    auto hack = [](const unsigned O) { return O - 0141 < 120; };
    std::copy_if(code.rbegin(), code.rend(),
        std::ostream_iterator<const char>(std::cout), hack);
    std::cout << '\n';
}

출력:

password

참고 항목

(C++23)
역방향 반복자를 끝으로 반환
(public member function)
컨테이너나 배열의 시작을 가리키는 역방향 반복자를 반환
(function template)