fork(3) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. template<typename T, typename... Args>
  6. void push_back_vec(vector<T>& vec, Args&&... args)
  7. {
  8. ((void)vec.push_back(forward<Args>(args)), ...);
  9. }
  10.  
  11. int main()
  12. {
  13. int x = 1, y = 2;
  14. vector<int> v{};
  15.  
  16. push_back_vec(v, 0, x, y);
  17. push_back_vec(v, 3, 3 + x, 3 + y);
  18.  
  19. for (const auto& i : v) cout << i << " ";
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5