std::basic_string_view<CharT,Traits>::end, std::basic_string_view<CharT,Traits>::cend
來自 cppreference.com
< cpp | string | basic string view
constexpr const_iterator end() const noexcept; |
(C++17 起) | |
constexpr const_iterator cend() const noexcept; |
(C++17 起) | |
返回一個指向檢視中最後一個字元之後字元的迭代器。這個字元作為佔位符,嘗試訪問它會導致未定義行為。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
指向最後一個字元之後字元的 const_iterator
。
[編輯] 複雜度
常數時間。
[編輯] 示例
執行此程式碼
#include <iostream> #include <iterator> #include <string_view> int main() { constexpr std::string_view str_view("abcd"); constexpr auto end = str_view.end(); constexpr auto cend = str_view.cend(); static_assert ( *std::prev(end) == 'd' && 'd' == *std::prev(cend) and end == cend ); }
[編輯] 參閱
返回指向起始的迭代器 (public member function) | |
(C++11) |
返回指向末尾的迭代器 ( std::basic_string<CharT,Traits,Allocator> 的公共成員函式) |