fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <functional>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. vector<int> v;
  10. int counter = -3;
  11. generate_n(back_inserter(v), 10 , [&counter] () -> int { return counter++; });
  12. for (int i=0;i!=v.size();i++) cout << v[i] << endl;
  13. return 0;
  14. }
Success #stdin #stdout 0s 3060KB
stdin
Standard input is empty
stdout
-3
-2
-1
0
1
2
3
4
5
6