std::basic_string_view<CharT,Traits>::rbegin, std::basic_string_view<CharT,Traits>::crbegin
來自 cppreference.com
< cpp | string | basic string view
constexpr const_reverse_iterator rbegin() const noexcept; |
(C++17 起) | |
constexpr const_reverse_iterator crbegin() 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(), std::next(str_view.rbegin(), 3), out_it); *out_it = '\n'; std::copy(str_view.crbegin(), std::next(str_view.crbegin(), 3), out_it); *out_it = '\n'; }
輸出
fed fed
[編輯] 參閱
返回指向末尾的逆向迭代器 (public member function) | |
(C++11) |
返回指向起始的逆向迭代器 ( std::basic_string<CharT,Traits,Allocator> 的公共成員函式) |