Namespaces
Variants

std::basic_string_view<CharT,Traits>:: rbegin, std::basic_string_view<CharT,Traits>:: crbegin

From cppreference.net
constexpr const_reverse_iterator rbegin ( ) const noexcept ;
(depuis C++17)
constexpr const_reverse_iterator crbegin ( ) const noexcept ;
(depuis C++17)

Retourne un itérateur inverse vers le premier caractère de la vue inversée. Il correspond au dernier caractère de la vue non inversée.

range-rbegin-rend.svg

Table des matières

Paramètres

(aucun)

Valeur de retour

const_reverse_iterator vers le premier caractère.

Complexité

Constante.

Exemple

#include <algorithm>
#include <iostream>
#include <iterator>
#include <string_view>
int main()
{
    std::ostream_iterator<char> out_it(std::cout);
    std::string_view str_view("abcdef");
    std::copy(str_view.rbegin(), std::next(str_view.rbegin(), 3), out_it);
    *out_it = '\n';
    std::copy(str_view.crbegin(), std::next(str_view.crbegin(), 3), out_it);
    *out_it = '\n';
}

Sortie :

fed
fed

Voir aussi

retourne un itérateur inverse vers la fin
(fonction membre publique)
retourne un itérateur inverse vers le début
(fonction membre publique de std::basic_string<CharT,Traits,Allocator> )