std::basic_string_view<CharT,Traits>::rend, std::basic_string_view<CharT,Traits>::crend
來自 cppreference.com
< cpp | string | basic_string_view
constexpr const_reverse_iterator rend() const noexcept; |
(C++17 起) | |
constexpr const_reverse_iterator crend() const noexcept; |
(C++17 起) | |
返回一個逆向迭代器,指向反向檢視中最後一個字元的後一個字元。它對應於非反向檢視中第一個字元的前一個字元。此字元充當佔位符,嘗試訪問它會導致未定義行為。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
指向最後一個字元的後一個字元的 const_reverse_iterator
。
[編輯] 複雜度
常數時間。
[編輯] 示例
執行此程式碼
#include <algorithm> #include <iostream> #include <iterator> #include <string_view> int main() { std::ostream_iterator<char> out_it(std::cout); std::string_view str_view("abcdef"); std::copy(str_view.rbegin(), str_view.rend(), out_it); *out_it = '\n'; std::copy(str_view.crbegin(), str_view.crend(), out_it); *out_it = '\n'; }
輸出
fedcba fedcba
[編輯] 參閱
返回指向起始的逆向迭代器 (公共成員函式) | |
(C++11) |
返回指向末尾的逆向迭代器 ( std::basic_string<CharT,Traits,Allocator> 的公共成員函式) |