名稱空間
變體
操作

std::basic_string_view<CharT,Traits>::rbegin, std::basic_string_view<CharT,Traits>::crbegin

來自 cppreference.com
 
 
 
 
constexpr const_reverse_iterator rbegin() const noexcept;
(C++17 起)
constexpr const_reverse_iterator crbegin() const noexcept;
(C++17 起)

返回指向反向檢視的第一個字元的反向迭代器。它對應於非反向檢視的最後一個字元。

range-rbegin-rend.svg

目錄

[編輯] 引數

(無)

[編輯] 返回值

指向第一個字元的 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) [編輯]
返回指向起始的逆向迭代器
(std::basic_string<CharT,Traits,Allocator> 的公共成員函式) [編輯]