#include <iostream>
#include <list>
#include <vector>
int main ()
{
std::list<int> mylist;
std::list<int>::iterator it;
std::list<int> otherList;
std::list<int> combinedList;
// set some initial values:
for (int i=1; i<=5; ++i) mylist.push_back(i); // 1 2 3 4 5
for (int i=6; i<=10; i++) otherList.push_back(i); // 6 7 8 9 10
std::list<int> temp = otherList;
combinedList = mylist;
it = combinedList.begin();
combinedList.splice(it, temp);
std::cout << "mylist contains:";
for (it=combinedList.begin(); it!=combinedList.end(); ++it)
std::cout << ' ' << *it;
std::cout << '\n';
std::cout<<"orignal appended list:"<<std::endl;
for(it=otherList.begin(); it!=otherList.end(); ++it)
std::cout<<' '<<*it;
std::cout<<'\n';
return 0;
}
~
~
~
~