std::basic_string<CharT,Traits,Allocator>::end, std::basic_string<CharT,Traits,Allocator>::cend
來自 cppreference.com
< cpp | string | basic_string
iterator end(); |
(1) | (C++11 起無異常丟擲) (C++20 起為 constexpr) |
const_iterator end() const; |
(2) | (C++11 起無異常丟擲) (C++20 起為 constexpr) |
const_iterator cend() const noexcept; |
(3) | (C++11 起) (C++20 起為 constexpr) |
返回指向字串最後一個字元之後位置的迭代器。此字元充當佔位符,嘗試訪問它會導致未定義行為。
目錄 |
[編輯] 引數
(無)
[編輯] 返回值
指向最後一個字元之後位置的迭代器。
[編輯] 複雜度
常數時間。
[編輯] 注意
libc++ 將 cend()
反向移植到 C++98 模式。
[編輯] 示例
執行此程式碼
#include <algorithm> #include <iostream> #include <iterator> #include <string> int main() { std::string s("Exemparl"); std::next_permutation(s.begin(), s.end()); std::string c; std::copy(s.cbegin(), s.cend(), std::back_inserter(c)); std::cout << c << '\n'; // "Exemplar" }
輸出
Exemplar
[編輯] 參閱
(C++11) |
返回指向起始的迭代器 (public member function) |
返回指向末尾的迭代器 ( std::basic_string_view<CharT,Traits> 的公共成員函式) |