Namespaces
Variants

std::basic_string_view<CharT,Traits>:: begin, std::basic_string_view<CharT,Traits>:: cbegin

From cppreference.net
constexpr const_iterator begin ( ) const noexcept ;
(C++17 起)
constexpr const_iterator cbegin ( ) const noexcept ;
(C++17 起)

返回指向视图首字符的迭代器。

range-begin-end.svg

目录

参数

(无)

返回值

const_iterator 指向第一个字符。

复杂度

常量。

示例

#include <concepts>
#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)>);
}

参见

返回指向末尾的迭代器
(公开成员函数)
返回指向起始位置的迭代器
( std::basic_string<CharT,Traits,Allocator> 的公开成员函数)