fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. template<class Iter>
  7. auto my_func(Iter beg, Iter end)
  8. {
  9. return vector<typename iterator_traits<Iter>::value_type> (beg, end);
  10. }
  11.  
  12. int main() {
  13. int bips[] = { 3,7,0,60,17 };//Passing pointers of array
  14. auto g = my_func(bips, bips + sizeof(bips) / sizeof(*bips));
  15.  
  16. for(const auto i : g) cout << i << '\t';
  17. cout << endl;
  18.  
  19. vector<int> v = { 10,5,4,14 };//Passing iterators of a vector
  20. auto h = my_func(v.begin(), v.end());
  21.  
  22. for(const auto i : h) cout << i << '\t';
  23. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
3	7	0	60	17	
10	5	4	14