std::basic_string_view<CharT,Traits>::end, std::basic_string_view<CharT,Traits>::cend

来自cppreference.com
 
 
 
 
constexpr const_iterator end()constnoexcept;
(C++17 起)
constexpr const_iterator cend()constnoexcept;
(C++17 起)

返回指向视图末字符后一字符的迭代器。此字符表现为占位符,试图访问它会导致未定义行为。

range-begin-end.svg

目录

[编辑]参数

(无)

[编辑]返回值

指向末字符后一字符的 const_iterator

[编辑]复杂度

常数。

[编辑]示例

#include <iostream>#include <iterator>#include <string_view>   int main(){constexprstd::string_view str_view("abcd");constexprauto end = str_view.end();constexprauto cend = str_view.cend();   static_assert (*std::prev(end)=='d'&&'d'==*std::prev(cend) and end == cend );}

[编辑]参阅

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