Espaces de noms
Variantes
Affichages
Actions

std::reverse_iterator

De cppreference.com
< cpp‎ | iterator
 
 
Bibliothèque Iterator
Primitives Iterator
Original:
Iterator primitives
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iterator_traits
input_iterator_tag
output_iterator_tag
forward_iterator_tag
bidirectional_iterator_tag
random_access_iterator_tag
iterator
Adaptateurs Iterator
Original:
Iterator adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
reverse_iterator
Itérateurs de flux
Original:
Stream iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istream_iterator
ostream_iterator
istreambuf_iterator
ostreambuf_iterator
Opérations Iterator
Original:
Iterator operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
advance
distance
prev (C++11)
next (C++11)
Gamme d'accès
Original:
Range access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
begin (C++11)
end (C++11)
 
std::reverse_iterator
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
reverse_iterator::reverse_iterator
reverse_iterator::operator=
reverse_iterator::base
reverse_iterator::operator*
reverse_iterator::operator->
reverse_iterator::operator[]
reverse_iterator::operator++
reverse_iterator::operator+
reverse_iterator::operator+=
reverse_iterator::operator--
reverse_iterator::operator-
reverse_iterator::operator-=
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator==
operator!=
operator<
operator>
operator+
operator-
 
Déclaré dans l'en-tête <iterator>
template< class Iterator >

class reverse_iterator : public std::iterator<
                           typename std::iterator_traits<Iterator>::iterator_category,
                           typename std::iterator_traits<Iterator>::value_type,
                           typename std::iterator_traits<Iterator>::difference_type,
                           typename std::iterator_traits<Iterator>::pointer,

                           typename std::iterator_traits<Iterator>::reference >

std::reverse_iterator est un adaptateur d'itérateur qui inverse le sens d'un itérateur donné. En d'autres termes, lorsqu'il est fourni avec un itérateur bidirectionnel, std::reverse_iterator produit un nouvel itérateur qui se déplace depuis la fin jusqu'au début de la séquence définie par l'itérateur bidirectionnel sous-jacent.

Pour un std::reverse_iterator noté r construit à partir d'un itérateur i, la relation &*r == &*(i-1) est toujours vraie, donc un std::reverse_iterator construit à partir d'un itérateur pointant sur l'élément juste après la fin déréférence le dernier élément d'une séquence.

C'est l'itérateur retourné par les fonctions membres rbegin() et rend() des conteneurs de la bibliothèque standard.

Sommaire

[modifier] Types de membres

Type de membre Définition
iterator_type Iterator
difference_type std::iterator_traits<Iterator>::difference_type
pointer std::iterator_traits<Iterator>::pointer
reference std::iterator_traits<Iterator>::reference

[modifier] Fonctions membres

construit un nouvel itérateur adaptateur
Original:
constructs a new iterator adaptor
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
assigne un autre itérateur
Original:
assigns another iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
accède à l'itérateur sous-jacent
Original:
accesses the underlying iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
accède à l'élément pointé vers
Original:
accesses the pointed-to element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
obtient de référence rvalue à l'élément indexé
Original:
obtains rvalue reference to indexed element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
avances ou décrémente l'itérateur
Original:
advances or decrements the iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]

[modifier] Objets membres

Nom du membre Définition
current (protégé) une copie de l'itérateur base()

En plus de la valeur courante de l'itérateur sous-jacent, une implémentation classique de std::reverse_iterator est de garder une copie de l'itérateur sous-jacent décrémenté, qui sera utilisé dans le déréférencement.

[modifier] Fonctions tierces

compare les itérateurs sous-jacents
Original:
compares the underlying iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
progrès de l'itérateur
Original:
advances the iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]
calcule la distance entre deux adaptateurs itérateur
Original:
computes the distance between two iterator adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction générique) [edit]

Inherited from std::iterator

Member types

Type du membre Définition
value_type  std::iterator_traits<Iterator>::value_type
difference_type  std::iterator_traits<Iterator>::difference_type
pointer  std::iterator_traits<Iterator>::pointer
reference  std::iterator_traits<Iterator>::reference
iterator_category  std::iterator_traits<Iterator>::iterator_category

[modifier] Exemple

#include <iostream>
#include <string>
#include <iterator>
 
int main()
{
    std::string s = "Hello, world";
    std::reverse_iterator<std::string::iterator> r = s.rbegin();
    r[7] = 'O'; // remplace 'o' avec 'O' 
    r += 7; // l'itérateur pointe désormais sur 'O'
    std::string rev(r, s.rend());
    std::cout << rev << '\n';
}

Résultat :

OlleH

[modifier] Voir aussi

l'itérateur de base
Original:
the basic iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(classe générique) [edit]