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()constnoexcept; | (C++17 起) | |
constexpr const_iterator cbegin()constnoexcept; | (C++17 起) | |
返回指向视图首字符的迭代器。
目录 |
[编辑]参数
(无)
[编辑]返回值
指向首字符的 const_iterator
。
[编辑]复杂度
常数。
[编辑]示例
运行此代码
#include <iostream>#include <string_view> int main(){constexprstd::string_view str_view("abcd"); constexprauto begin = str_view.begin();constexprauto cbegin = str_view.cbegin(); static_assert(*begin =='a' and *cbegin =='a' and *begin ==*cbegin and begin == cbegin and std::same_as<decltype(begin), decltype(cbegin)>);}
[编辑]参阅
返回指向结尾的迭代器 (公开成员函数) | |
(C++11) | 返回指向起始的迭代器 ( std::basic_string<CharT,Traits,Allocator> 的公开成员函数) |