fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4. #include <algorithm>
  5.  
  6. template <class T>
  7. using vector = std::vector<T>;
  8.  
  9. template <class T>
  10. using list = std::list<T>;
  11.  
  12. template <class T, template <class> class C1, template <class> class C2>
  13. void test(C1<T>& c1, C2<T>& c2)
  14. {
  15. while (c1.size() > 0)
  16. {
  17. c2.push_front(c1.back());
  18. c1.pop_back();
  19. }
  20. }
  21.  
  22. int main()
  23. {
  24. vector<int> v;
  25. list <int> l;
  26.  
  27. v.reserve(10);
  28. for (int i = 0; i < 10; ++i)
  29. v.push_back(i);
  30.  
  31. test<int, vector, list>(v, l);
  32.  
  33. std::for_each(l.begin(), l.end(),
  34. [] (int i) { std::cout << i << " "; }
  35. );
  36.  
  37. std::cout << std::endl;
  38.  
  39. return 0;
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:1: error: expected unqualified-id before 'using'
prog.cpp:10:1: error: expected unqualified-id before 'using'
prog.cpp: In function 'int main()':
prog.cpp:24:3: error: 'vector' was not declared in this scope
prog.cpp:24:10: error: expected primary-expression before 'int'
prog.cpp:24:10: error: expected ';' before 'int'
prog.cpp:25:3: error: 'list' was not declared in this scope
prog.cpp:25:10: error: expected primary-expression before 'int'
prog.cpp:25:10: error: expected ';' before 'int'
prog.cpp:27:3: error: 'v' was not declared in this scope
prog.cpp:31:13: error: 'vector' cannot appear in a constant-expression
prog.cpp:31:21: error: 'list' cannot appear in a constant-expression
prog.cpp:31:30: error: 'l' was not declared in this scope
stdout
Standard output is empty