◐ Shell
clean mode source ↗

std::basic_string_view<CharT,Traits>::begin, std::basic_string_view<CharT,Traits>::cbegin - cppreference.com

提供: 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';
}

出力:

関連項目