std::span<T,Extent>::rbegin, std::span<T,Extent>::crbegin
來自 cppreference.com
constexpr reverse_iterator rbegin() const noexcept; |
(1) | (C++20 起) |
constexpr const_reverse_iterator crbegin() const noexcept; |
(2) | (C++23 起) |
返回反轉的 span
的第一個元素的逆向迭代器。它對應於非反轉 span
的最後一個元素。如果 span
為空,則返回的迭代器等於 rend()。
目錄 |
[編輯] 返回值
指向第一個元素的逆向迭代器。
[編輯] 複雜度
常數時間。
[編輯] 注意
返回的逆向迭代器的底層迭代器是末尾迭代器。因此,如果末尾迭代器失效,則返回的迭代器也失效。
[編輯] 示例
執行此程式碼
#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); std::cout << '\n'; }
輸出
password
[編輯] 參閱
(C++23) |
返回指向末尾的逆向迭代器 (公共成員函式) |
(C++14) |
返回指向容器或陣列開頭的反向迭代器 (函式模板) |