language: C++11 (gcc-4.7.2)
date: 199 days 4 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
 
template<typename Type, typename... Args> 
void apply(std::vector<Type> &v, void(*algo)(Type*, Type*, Args...), Args... args)
{
    algo(&*v.begin(), &*v.end(), args...);
}
 
int main()
{
    std::vector<int> v(10, 50);
    apply<int, int>(v, std::iota, 3);
    for (unsigned int i = 0; i < v.size(); ++i) {
       std::cout<<v[i]<<std::endl;
    }
}