命名空间
变体
操作

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

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

返回指向反向视图首字符的反向迭代器。它对应于非反向视图的最后一个字符。

range-rbegin-rend.svg

目录

[edit] 参数

(无)

[edit] 返回值

指向首字符的 const_reverse_iterator

[edit] 复杂度

常数。

[edit] 示例

#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

[edit] 参见

返回指向末尾的反向迭代器
(公开成员函数) [编辑]
返回指向起始位置的反向迭代器
(std::basic_string<CharT,Traits,Allocator> 的公开成员函数) [编辑]