title: Nice way to truncate an integer
body: <p>I have a function which is given a buffer which accepts to be filled up to a <code>size_t</code> length; however, the actual call which fills it wants an <code>int</code> as max length. </p>
  
  <p>So, in case the parameter cannot fit in an integer, I want it truncated to the maximum value that can fit; as I couldn't get more data anyway. </p>
  
  <p>I can do this</p>
  
  <pre><code>int truncatedMaxLen = static_cast&lt;int&gt;(std::min&lt;std::size_t&gt;(maxLength, (std::numeric_limits&lt;int&gt;::max)()));
  </code></pre>
  
  <p>Any less ugly ways?</p>