title: Choose m elements randomly from a vector containing n elements
body: <p>I have a vector containing <code>n</code> elements. I need to choose a subset of <code>m</code> elements randomly from the vector without repetition. What is the most efficient way of doing this? I need to do this several thousands of times in my code.</p>
  
  <p>The solution on top of my mind is to use <code>rand()</code> to generate a random number <code>k</code> between <code>0</code> and <code>n</code>. Then pick the <code>k</code>th element in the vector and insert it into a <code>std::set</code>. Keep doing this till the set's size becomes equal to <code>m</code>. I am now assured that the set contains <code>m</code> unique elements randomly chosen from the set of <code>n</code> elements.</p>
  
  <p>What are the other possible solutions?</p>
  
  <p>Thanks.</p>