命名空间
变体
操作

std::basic_string_view<CharT,Traits>::rend, std::basic_string_view<CharT,Traits>::crend

来自 cppreference.cn
 
 
 
 
constexpr const_reverse_iterator rend() const noexcept;
(自 C++17 起)
constexpr const_reverse_iterator crend() 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(), str_view.rend(), out_it);
    *out_it = '\n';
 
    std::copy(str_view.crbegin(), str_view.crend(), out_it);
    *out_it = '\n';
}

输出

fedcba
fedcba

[edit] 参见

返回指向开头的反向迭代器
(公共成员函数) [编辑]
(C++11)
返回指向结尾的反向迭代器
(std::basic_string<CharT,Traits,Allocator> 的公共成员函数) [编辑]