title: C++ set: counting elements less than a value
body: <p>Assuming a I have an STL <code>set &lt;int&gt; s</code> and an <code>int x</code>, how can I count the number of elements in <code>s</code> that are less than <code>x</code>?</p>
  
  <p>I'm seeking an <code>O(log n)</code> (or similar; anything that's reasonably better than <code>O(n)</code>) solution;</p>
  
  <p>I already know about <code>std::distance(s.begin(), s.lower_bound(x))</code>, but that's <code>O(n)</code>, I believe, because <code>set</code>s aren't random-access.</p>