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 ;
(desde C++17)
constexpr const_iterator cbegin ( ) const noexcept ;
(desde C++17)

Devuelve un iterador al primer carácter de la vista.

range-begin-end.svg

Contenidos

Parámetros

(ninguno)

Valor de retorno

const_iterator al primer carácter.

Complejidad

Constante.

Ejemplo

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

Véase también

devuelve un iterador al final
(función miembro pública)
devuelve un iterador al inicio
(función miembro pública de std::basic_string<CharT,Traits,Allocator> )