fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4. #include <algorithm>
  5.  
  6. struct vector_wrapper
  7. {
  8. template <typename T>
  9. struct instance_wrapper
  10. {
  11. typedef typename std::vector<T> instance;
  12. };
  13. };
  14.  
  15. struct list_wrapper
  16. {
  17. template <typename T>
  18. struct instance_wrapper
  19. {
  20. typedef typename std::list<T> instance;
  21. };
  22. };
  23.  
  24. template <typename T, typename C1, typename C2>
  25. void move(typename C1::instance_wrapper<T>::instance& c1, typename C2::instance_wrapper<T>::instance& c2) // line 29
  26. {
  27. while (c1.size() > 0)
  28. {
  29. c2.push_front(c1.back());
  30. c1.pop_back();
  31. }
  32. }
  33.  
  34. int main()
  35. {
  36. std::vector<int> v;
  37. std::list <int> l;
  38.  
  39. v.reserve(10);
  40. for (int i = 0; i < 10; ++i)
  41. v.push_back(i);
  42.  
  43. move<int, vector_wrapper, list_wrapper>(v, l);
  44.  
  45. std::for_each(l.begin(), l.end(),
  46. [] (int i) { std::cout << i << " "; }
  47. );
  48.  
  49. std::cout << std::endl;
  50.  
  51. return 0;
  52. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:25:24: error: non-template 'instance_wrapper' used as template
prog.cpp:25:24: note: use 'C1::template instance_wrapper' to indicate that it is a template
prog.cpp:25:72: error: non-template 'instance_wrapper' used as template
prog.cpp:25:72: note: use 'C2::template instance_wrapper' to indicate that it is a template
prog.cpp: In function 'void move(typename C1::instance_wrapper, typename C2::instance_wrapper)':
prog.cpp:27:10: error: 'c1' was not declared in this scope
prog.cpp:29:5: error: 'c2' was not declared in this scope
prog.cpp: In function 'int main()':
prog.cpp:43:47: error: no matching function for call to 'move(std::vector<int>&, std::list<int>&)'
stdout
Standard output is empty