Spec-Zone.ru › C++

std::basic_string_view<CharT,Traits>::end, std::basic_string_view<CharT,Traits>::cend

constexpr const_iterator end() const noexcept;
(since C++17)
constexpr const_iterator cend() const noexcept;
(since C++17)

Возвращает итератор на символ, следующий за последним символом представления. Этот символ используется как плейсхолдер, попытка доступа к нему приводит к неопределённому поведению.

range-begin-end.svg

Параметры

(нет)

Возвращаемое значение

const_iterator на символ, следующий за последним символом.

Сложность

Постоянная.

Пример

#include <iostream>
#include <iterator>
#include <string_view>
 
int main()
{
    constexpr std::string_view str_view("abcd");
    constexpr auto end = str_view.end();
    constexpr auto cend = str_view.cend();
 
    static_assert
    (
        *std::prev(end) == 'd' && 'd' == *std::prev(cend) and end == cend
    );
}

См. также

begincbegin
возвращает итератор к началу
(публичный член-функция)
endcend
(DR*)
возвращает итератор к концу
(публичный член-функция std::basic_string<CharT,Traits,Allocator>)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/string/basic_string_view/end

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API