Obtaining max of unsigned integer with bitwise not on zero value
<p>I'm trying to obtain the maximum value of a certain unsigned integer type without including any headers like <code>&lt;limits&gt;</code>. So I thought I'd simply flip the bits of the unsigned integer value 0.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;limits&gt;

int main()
{
    std::cout &lt;&lt; (~0U) &lt;&lt; '\n'; // #1
    std::cout &lt;&lt; (std::numeric_limits&lt; unsigned &gt;::max()) &lt;&lt; '\n'; // #2
    return 0;
}
</code></pre>

<p>I'm not very experienced on the subtle differences between these. Which is why I'm asking if some unexpected behavior or some platform/architecture issues could occur by using the first method.</p>