Namespaces
Variants

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

From cppreference.net
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> 的公开成员函数)