title: Is clamping on iterators valid
body: <p>I found the following in actual production code.
  My suspicion is that it actually has undefined behavior into it, however, I couldn't find the related info on cppreference. Can you confirm this is UB or valid code and why this is UB/valid (preferably with a quote of the standard)?</p>
  <pre><code>#include &lt;vector&gt;
  
  int main(int, char **)
  {
      auto v = std::vector&lt;int&gt;({1,2,3,4,5});
      auto begin = v.begin();
      auto outOfRange = begin + 10;
      auto end = v.end();
      auto clamped = std::min(outOfRange, end);
      return (clamped == end) ? 0 : 42;
  }
  </code></pre>
  <p><a href="https://compiler-explorer.com/z/cag2Ce" rel="nofollow noreferrer">Code on Compiler Explorer</a></p>
  <p>As you can see <code>begin + 10</code> will create an iterator that's out of range of the <code>std::vector</code>.
  However, that iterator ain't being used, as it is clamped using <code>std::min</code>.</p>