Use copy_backward to copy value from vector to a list : copy_backward « STL Algorithms Non modifying sequence operations « C++ Tutorial






#include <algorithm>
#include <vector>
#include <list>
#include <iostream>

using namespace std;

int main (){
    list <int> l;

    for (int nCount = 0; nCount < 10; ++ nCount)
        l.push_back (nCount);

    list <int>::const_iterator li;
    for ( li = l.begin (); li != l.end (); ++ li )
        cout << *li << ' ';

    vector <int> v (l.size () * 2);

    copy_backward ( l.begin (), l.end (), v.end () );

    vector <int>::const_iterator vi;
    for ( vi = v.begin (); vi != v.end (); ++ vi )
        cout << *vi << ' ';

    return 0;
}








25.3.copy_backward
25.3.1.Use the copy_backward algorithms: Shift it right by 2 positions
25.3.2.Use std::copy_backward to place elements in one vector into another vector in reverse order
25.3.3.Use copy_backward to copy value from vector to a list
25.3.4.copy_backward, merge, unique and reverse.