W3cubDocs

/C++

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

constexpr reverse_iterator rbegin() const noexcept;
(since C++20)

Returns a reverse iterator to the first element of the reversed span. It corresponds to the last element of the non-reversed span. If the span is empty, the returned iterator is equal to rend().

range-rbegin-rend.svg

Parameters

(none).

Return value

Reverse iterator to the first element.

Complexity

Constant.

Example

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

Output:

password

See also

(C++20)
returns a reverse iterator to the end
(public member function)
(C++14)
returns a reverse iterator to the beginning of a container or array
(function template)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/container/span/rbegin