名前空間
変種

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

提供: cppreference.com
 
 
 
 
<tbody> </tbody>
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

関連項目

終端を指すイテレータを返します
(パブリックメンバ関数) [edit]