std::span<T,Extent>::rbegin, std::span<T,Extent>::crbegin - cppreference.com

From cppreference.com

constexprreverse_iteratorrbegin()constnoexcept; (1) (since C++20)constexprconst_reverse_iteratorcrbegin()constnoexcept; (2) (since C++23)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().

Return value

Reverse iterator to the first element.

Complexity

Constant.

Notes

The

underlying iterator

of the returned reverse iterator is the

end iterator

. Hence the returned iterator is invalidated if and when the end iterator is invalidated.

Example

Run this code

#include<algorithm>#include<iostream>#include<iterator>#include<span>intmain(){constexprstd::span<constchar>code{"@droNE_T0P_w$s@s#_SECRET_a,p^42!"};autohack=[](constunsignedO){returnO-0141<120;};std::copy_if(code.rbegin(),code.rend(),std::ostream_iterator<constchar>(std::cout),hack);std::cout<<'\n';}Output:

password See also

(C++23)

returns a reverse iterator to the end
(public member function)

[edit]

(C++14)

returns a reverse iterator to the beginning of a container or array
(function template)

[edit]