fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. template <typename T>
  5. std::vector<typename T::iterator> f(T t)
  6. {
  7. std::vector<typename T::iterator> v;
  8. for (auto i = t.begin(); i != t.end(); ++i)
  9. {
  10. v.push_back(i);
  11. }
  12. return v;
  13. }
  14.  
  15. template <typename T>
  16. void print(const std::vector<T>& v)
  17. {
  18. for (auto i = v.begin(); i != v.end(); ++i)
  19. {
  20. std::cout << **i << ' ';
  21. }
  22. std::cout << std::endl;
  23. }
  24.  
  25. int main()
  26. {
  27. std::vector<int> v{1, 2, 3};
  28. print(f(v));
  29. std::vector<std::vector<int>::iterator> itervec = f(v);
  30. print(itervec);
  31. }
  32.  
Success #stdin #stdout 0s 2964KB
stdin
Standard input is empty
stdout
1 2 3 
163487776 2 3