Code:
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
vector<int> IntVect;
for( int j = 0; j < 10; ++j )
IntVect.push_back(j);
copy( IntVect.begin(), IntVect.end(), ostream_iterator<int>(cout,"\n") );
return 0;
}
Outputs via cout:
0
1
2
3
4
5
6
7
8
9
You can use this to copy a vector container into a list container for example...
Code:
#include <vector>
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
int main()
{
vector<int> IntVect;
list<int> IntList;
for( int j = 0; j < 10; ++j )
IntVect.push_back(j);
// Copy contents of IntVect into IntList.
copy( IntVect.begin(), IntVect.end(), back_inserter(IntList) );
return 0;
}
[edit]Noticed some ';' that I needed to make ','. Sory for any confusion.[/edit]