fork(1) download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <vector>
  4.  
  5. template <typename OutputIterator>
  6. OutputIterator F1( OutputIterator out )
  7. {
  8. std::cout << "F1 was called\n";
  9. /* Insert stuff via *out++ = ...; */
  10. *out++ = 7;
  11. return out;
  12. }
  13.  
  14. int main()
  15. {
  16. std::vector<int> Concat;
  17. // perhaps reserve some moderate amount of storage to avoid reallocation
  18.  
  19. F1( std::back_inserter(Concat) );
  20. F1( std::back_inserter(Concat) );
  21.  
  22.  
  23. for (auto i : Concat)
  24. std::cout << i << ", ";
  25. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
F1 was called
F1 was called
7, 7,