fork download
  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. template<typename T, typename U>
  5. void call(T& array, U it, std::ostream& o)
  6. {
  7. if(it != std::end(array)) {
  8. o << *it;
  9. ++it;
  10. call(array, it, o);
  11. }
  12. }
  13.  
  14. int main()
  15. {
  16. for(int i = 0 ; i < 3 ; ++i) {
  17. std::stringstream s;
  18. int a[] = { 1, 2, 3, 4, 5, 6 };
  19. call(a, std::begin(a), s);
  20. std::cout << s.str() << std::endl;
  21. }
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
123456
123456
123456