Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- template <int N> class Numerable{
- public:
- template <typename F> static void times(F func){
- for(int i=0;i<N;i++){
- func(i);
- }
- }
- };
- int main(){
- vector<int> v;
- Numerable<10>::times([&v](int x)->void { v.push_back(x); });
- for_each(v.begin(), v.end(), [v](int x)->void { cout << v[x] << endl;} );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment