fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <numeric>
  4. #include <algorithm>
  5.  
  6. template<typename Type, typename... Args>
  7. void apply(std::vector<Type> &v, void(*algo)(Type*, Type*, Args...), Args... args)
  8. {
  9. algo(&*v.begin(), &*v.end(), args...);
  10. }
  11.  
  12. int main()
  13. {
  14. std::vector<int> v(10, 50);
  15. apply<int, int>(v, std::iota, 3);
  16. for (unsigned int i = 0; i < v.size(); ++i) {
  17. std::cout<<v[i]<<std::endl;
  18. }
  19. }
Success #stdin #stdout 0s 3060KB
stdin
Standard input is empty
stdout
3
4
5
6
7
8
9
10
11
12