fork(2) download
  1. #include <iostream>
  2. #include <functional>
  3. #include <random>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. default_random_engine generator;
  10.  
  11. int dist1Max = 10, dist2Max = 10;
  12.  
  13. uniform_int_distribution<int> dist1(1, dist1Max);
  14. uniform_int_distribution<int> dist2(1, dist2Max);
  15.  
  16. function<int()> boundDist1 = std::bind(dist1, std::ref(generator));
  17. function<int()> boundDist2 = std::bind(dist2, std::ref(generator));
  18.  
  19. for (int i=0; i<10; ++i)
  20. {
  21. cout << boundDist1() << " " << boundDist2() << endl;
  22. }
  23. cout << endl;
  24.  
  25. for (int i=0; i<10; ++i)
  26. {
  27. cout << dist1(generator) << " " << dist2(generator) << endl;
  28. }
  29. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
2 1
5 8
3 6
7 1
10 7
6 4
1 9
6 1
1 7
1 4

7 5
10 6
6 9
7 1
8 5
8 10
1 3
4 8
8 7
4 10