std::basic_string_view<CharT,Traits>::begin, std::basic_string_view<CharT,Traits>::cbegin
来自cppreference.com
< cpp | string | basic string view
| constexpr const_iterator begin() const noexcept; |
(C++17 起) | |
| constexpr const_iterator cbegin() const noexcept; |
(C++17 起) | |
返回指向视图首字符的迭代器。
目录 |
[编辑] 参数
(无)
[编辑] 返回值
指向首字符的 const_iterator
[编辑] 复杂度
常数
[编辑] 示例
运行此代码
#include <iostream> #include <string_view> int main() { std::string_view str_view("abcd"); auto begin = str_view.begin(); auto cbegin = str_view.cbegin(); std::cout << *begin << '\n'; std::cout << *cbegin << '\n'; std::cout << std::boolalpha << (begin == cbegin) << '\n'; std::cout << std::boolalpha << (*begin == *cbegin) << '\n'; }
输出:
a a true true
[编辑] 参阅
| 返回指向结尾的迭代器 (公开成员函数) |