fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4. using namespace std;
  5.  
  6. template <class Init1, class Init2, class OutIt>
  7. inline OutIt join_array(Init1 begin1, Init1 end1, Init2 begin2, Init2 end2, OutIt output)
  8. {
  9. return copy(begin2, end2, copy(begin1, end1, output));
  10. }
  11.  
  12. template <class Container1, class Container2, class ContainerOut>
  13. inline void join_container(const Container1& c1, const Container2& c2, ContainerOut& out)
  14. {
  15. join_array(begin(c1), end(c1), begin(c2), end(c2), begin(out));
  16. }
  17.  
  18. int main() {
  19. int a[] = {1,2,3,4};
  20. int b[] = {5,6,7,8};
  21. int c[8];
  22.  
  23. join_container(a, b, c);
  24.  
  25. for(int x : c) cout << x << endl;
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1
2
3
4
5
6
7
8