title: C++ set find value smaller but closer to x
body: <p>I looked at <code>lower_bound</code> and <code>upper_bound</code> in the C++ STL for <code>&lt;set&gt;</code>. I can't find a method, however, to get the value closest (from below) to another one in the set. Is there a simple way to get that or do I have to iterate the set?</p>
  
  <p>As an example, say my set contains the following integers <code>3 4 7 9</code>, then <code>closest(6) = 4</code> and <code>closest(4) = 4</code>.</p>