fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4.  
  5. using namespace std;
  6.  
  7. template <typename Seq1, typename Seq2, typename OutputIterator>
  8. void append(const Seq1 &seq1, const Seq2 &seq2, OutputIterator it)
  9. {
  10. for (auto a: seq1)
  11. *it = a;
  12. for (auto a: seq2)
  13. *it = a;
  14. }
  15.  
  16. int main()
  17. {
  18. vector<int> first = {1,2,3}, second = {4,5,6,7}, destination;
  19. append(first, second, back_inserter(destination));
  20. for (auto i: destination)
  21. cout << i << ' ';
  22. }
Success #stdin #stdout 0s 4256KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 7