std::copy_backward — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
| Déclaré dans l'en-tête <algorithm> |
||
|
|
||
Copie les éléments de la gamme, définie par [first, last), à une autre plage qui se termine à d_last. Les éléments sont copiés dans l'ordre inverse (le dernier élément est copié d'abord), mais leur ordre relatif est préservé .
Original:
Copies the elements from the range, defined by [first, last), to another range ending at d_last. The elements are copied in reverse order (the last element is copied first), but their relative order is preserved.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
| first, last | - | l'intervalle des éléments à copier Original: the range of the elements to copy The text has been machine-translated via Google Translate. |
| d_last | - | fin de la plage de destination. Si Original: end of the destination range. If The text has been machine-translated via Google Translate. |
| Type requirements | ||
-BidirIt must meet the requirements of BidirectionalIterator.
| ||
Retourne la valeur
itérateur sur le dernier élément copié .
Original:
iterator to the last element copied.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Complexité
Exactement last - first missions .
Original:
Exactly last - first assignments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Mise en œuvre possible
template< class BidirIt1, class BidirIt2 > BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last) { while (first != last) { *(--d_last) = *(--last); } return d_last; }
Exemple
#include <algorithm> #include <iostream> int main() { std::vector<int> from_vector; for (int i = 0; i < 10; i++) { from_vector.push_back(i); } std::vector<int> to_vector(15); std::copy_backward(from_vector.begin(), from_vector.end(), to_vector.end()); std::cout << "to_vector contains: "; for (unsigned int i = 0; i < to_vector.size(); i++) { std::cout << to_vector[i] << " "; } }
Résultat :
to_vector contains: 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9
Voir aussi
Copie une série d'éléments vers un nouvel emplacement Original: copies a range of elements to a new location The text has been machine-translated via Google Translate. (fonction générique) [edit] | |