fork download
  1. #include <list>
  2. #include <deque>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <iterator>
  6.  
  7. using namespace std;
  8.  
  9. template<typename T> ostream & print(const T & start, const T & end)
  10. {
  11. T tmp = start;
  12. for(; tmp != end; ++tmp)
  13. {
  14. cout<< *tmp<< " ";
  15. }
  16. return cout;
  17. }
  18. class A
  19. {
  20. public:
  21. int a;
  22. public:
  23. A(int a_):a(a_) {}
  24. };
  25.  
  26. ostream & operator<<(ostream & c, const A & o)
  27. {
  28. c<<o.a;
  29. return c;
  30. }
  31.  
  32. int main()
  33. {
  34. int tab[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  35. list<A> l1(tab, tab+10);
  36. deque<A> d1;
  37. copy(l1.begin(), l1.end(), std::back_inserter(d1));
  38. print(d1.begin(), d1.end())<<endl;
  39. return 0;
  40. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 7 8 9 10