title: How to seed a recursive c++ function
body: <p>I wrote this short program to randomly pick a subset of m elements out of {1,...,n} - </p>
  
  <pre><code>std::set&lt;int&gt; randSubSet(int n, int m){
    // generates a random subset of m elements from {1,...,n} uniformly
  
    if (m&gt;n) //check inputs validity
      throw std::invalid_argument("m is larger then n.");
  
    std::set&lt;int&gt; res{}; //initialize result set
  
    if (m==n){ //easy case - the full set
       for(int i = 1 ; i&lt;n ; ++i)
           res.insert(i);
    }
  
    std::mt19937 eng;
    std::uniform_int_distribution&lt;&gt; uni(1,n);
  
    if ( m == 0 ){ // recursion base case
  
        return res;
    }
    else {
        res = randSubSet(n-1,m-1);
        int i = uni(eng);
        if (res.find(i) == res.end()) // if i isn't in S add it
            res.insert(i);
        else
            res.insert(n); //else add n
  
    }
    return res;
  }
  </code></pre>
  
  <p>Since eng isn't seeded I always get the same answer. How do I seed eng in this senario? (since each call has it's own engine)</p>
  
  <p>I can avoid the problem using a global variable, I was wondering if there is any better solution. Thanks!</p>