命名空间
变体
操作

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

目录

[编辑] 参数

(无)

[编辑] 返回值

指向最后一个字符的后一个字符的 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> 的公共成员函数) [编辑]
English 日本語 中文(简体) 中文(繁體)