std::span<T,Extent>::rend, std::span<T,Extent>::crend
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Containers library
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
Tables
std::span
(C++26)
(C++23)
(C++23)
(C++23)
span::rendspan::crend
(C++23)
constexpr reverse_iterator rend() const noexcept;
(1)
(since C++20)
constexpr const_reverse_iterator crend() const noexcept;
(2)
(since C++23)
Returns a reverse iterator past the last element of the reversed *this. It corresponds to the element preceding the first element of the non-reversed *this.
This returned iterator only acts as a sentinel. It is not guaranteed to be dereferenceable.
Contents
[edit] Return value
Reverse iterator to the element following the last element.
[edit] Complexity
Constant.
[edit] Example
Run this code
#include <algorithm> #include <iostream> #include <span> #include <string_view> void ascending(const std::span <const std::string_view > data, const std::string_view term) { std::for_each (data.begin(), data.end(), [](const std::string_view x) { std::cout << x << ' '; }); std::cout << term; } void descending(const std::span <const std::string_view > data, const std::string_view term) { std::for_each (data.rbegin(), data.rend(), [](const std::string_view x) { std::cout << x << ' '; }); std::cout << term; } int main() { constexpr std::string_view bars[]{"▁","▂","▃","▄","▅","▆","▇","█"}; ascending(bars, " "); descending(bars, "\n"); }
Output:
▁ ▂ ▃ ▄ ▅ ▆ ▇ █ █ ▇ ▆ ▅ ▄ ▃ ▂ ▁