std::span rbegin() method
- od C++20
constexpr iterator rbegin() const noexcept;
Returns a reverse iterator
to the first element of the reversed view.It corresponds to the last element of the non reversed view.
If the span is empty, the returned iterator will be equal to rend()
.
This method doesn't actually reverse the view, it returns an iterator that points to the last element of the view,
and which +
, -
, --
, ++
operators have slightly changed implementations.
For example it++
decrements the internal pointer and it--
increments it (so that traversing the container in a reverse order actually works).
Parameters
(none)
Return value
Reverse iterator to the first element.
Complexity
Constant - O(1).
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 hacker = [](const unsigned O) { return O-0141<120; };
std::copy_if(code.rbegin(), code.rend(),
std::ostream_iterator<const char>(std::cout), hacker);
}
password
Hover to see the original license.