title: How to select a random element in std::set?
body: <p>How can I select a random element in an <code>std::set</code>? </p>
  
  <p>I naively tried this:</p>
  
  <pre><code>int GetSample(const std::set&lt;int&gt;&amp; s) {
    double r = rand() % s.size();
    return *(s.begin() + r); // compile error
  }
  </code></pre>
  
  <p>But the <code>operator+</code> is not allowed in this way.</p>