std::basic_string<CharT,Traits,Allocator>::end, std::basic_string<CharT,Traits,Allocator>::cend
来自 cppreference.cn
< cpp | string | basic string
iterator end(); |
(1) | (noexcept since C++11) (constexpr since C++20) |
const_iterator end() const; |
(2) | (noexcept since C++11) (constexpr since C++20) |
const_iterator cend() const noexcept; |
(3) | (since C++11) (constexpr since C++20) |
返回一个指向字符串中最后一个字符之后位置的迭代器。此字符充当占位符,尝试访问它会导致未定义的行为。
目录 |
[edit] 参数
(无)
[edit] 返回值
指向最后一个字符之后位置的迭代器。
[edit] 复杂度
常数。
[edit] 注释
libc++ 将 cend() 向后移植到 C++98 模式。
[edit] 示例
运行此代码
#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
[edit] 参见
(C++11) |
返回指向开头的迭代器 (公共成员函数) |
返回指向结尾的迭代器 (std::basic_string_view<CharT,Traits> 的公共成员函数) |