std::basic_string_view<CharT,Traits>::begin, std::basic_string_view<CharT,Traits>::cbegin - cppreference.com
来自cppreference.com
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() { constexpr std::string_view str_view("abcd"); constexpr auto begin = str_view.begin(); constexpr auto 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)>); }