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

来自cppreference.com
 
 
 
 
constexpr const_reverse_iterator rend()constnoexcept;
(C++17 起)
constexpr const_reverse_iterator crend()constnoexcept;
(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> 的公开成员函数)[编辑]
close