stdcrend
std::crend is a function in the C++ standard library that returns a const_reverse_iterator to the end of a reversed range. Introduced in C++11 and defined in the<iterator> header, it is the const counterpart to std::rend and is used together with std::crbegin to perform read-only reverse iteration over a container or array.
std::crend provides the end sentinel for reverse iteration. When paired with std::crbegin, it defines a range
- for (auto it = std::crbegin(v); it != std::crend(v); ++it) { use *it; }
This will access the elements of v in reverse order without mutating them. For readability, some code
std::crend is the const version of std::rend and pairs with std::crbegin to enable read-only reverse traversal.
There are overloads of std::crend for standard containers and for array types. In modern C++ (C++20 and