Boost C++ Libraries: Ticket #3342: vector_c should use maximum integral constant type https://svn.boost.org/trac10/ticket/3342 <p> It looks like currently long is built in, which leads to problems on 32 bit architectures with sizeofs int = long &lt; int64_t. </p> <p> How it's defined currently: </p> <div class="wiki-code"><div class="code"><pre><span class="k">template</span><span class="o">&lt;</span> <span class="k">typename</span> <span class="n">T</span><span class="p">,</span> <span class="kt">long</span> <span class="n">C0</span> <span class="o">=</span> <span class="n">LONG_MAX</span><span class="p">,</span> <span class="kt">long</span> <span class="n">C1</span> <span class="o">=</span> <span class="n">LONG_MAX</span><span class="p">,</span> <span class="kt">long</span> <span class="n">C2</span> <span class="o">=</span> <span class="n">LONG_MAX</span><span class="p">,</span> <span class="p">...</span> <span class="o">&gt;</span> <span class="k">struct</span> <span class="n">vector_c</span><span class="p">;</span> </pre></div></div><p> I believe the maximum integral type (e.g. int64_t) should be used instead of long. </p> <p> Example that shows the problem: </p> <div class="wiki-code"><div class="code"><pre> <span class="k">const</span> <span class="kt">int64_t</span> <span class="n">max_int</span> <span class="o">=</span> <span class="n">integer_traits</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;::</span><span class="n">const_max</span><span class="p">;</span> <span class="k">const</span> <span class="kt">int64_t</span> <span class="n">max_int_plus_1</span> <span class="o">=</span> <span class="n">max_int</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span> <span class="n">BOOST_MPL_ASSERT</span><span class="p">((</span> <span class="n">equal</span><span class="o">&lt;</span> <span class="n">vector_c</span><span class="o">&lt;</span> <span class="kt">int64_t</span><span class="p">,</span> <span class="mi">1</span> <span class="o">&gt;</span> <span class="p">,</span> <span class="n">vector</span><span class="o">&lt;</span> <span class="n">integral_c</span><span class="o">&lt;</span> <span class="kt">int64_t</span><span class="p">,</span> <span class="mi">1</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="p">));</span> <span class="n">BOOST_MPL_ASSERT</span><span class="p">((</span> <span class="n">equal</span><span class="o">&lt;</span> <span class="n">vector_c</span><span class="o">&lt;</span> <span class="kt">int64_t</span><span class="p">,</span> <span class="n">max_int</span> <span class="o">&gt;</span> <span class="p">,</span> <span class="n">vector</span><span class="o">&lt;</span> <span class="n">integral_c</span><span class="o">&lt;</span> <span class="kt">int64_t</span><span class="p">,</span> <span class="n">max_int</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="p">));</span> <span class="n">BOOST_MPL_ASSERT</span><span class="p">((</span> <span class="n">equal</span><span class="o">&lt;</span> <span class="n">vector_c</span><span class="o">&lt;</span> <span class="kt">int64_t</span><span class="p">,</span> <span class="n">max_int_plus_1</span> <span class="o">&gt;</span> <span class="p">,</span> <span class="n">vector</span><span class="o">&lt;</span> <span class="n">integral_c</span><span class="o">&lt;</span> <span class="kt">int64_t</span><span class="p">,</span> <span class="n">max_int_plus_1</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="p">));</span> </pre></div></div><p> The first assert passes, while the second and third fail with the following error messages (removed repetition of 2147483647l for readability): </p> <pre class="wiki">test.h:149: error: ************mpl::equal&lt;mpl::vector_c&lt;int64_t, 2147483647l, 2147483647l, ...&gt;, mpl::vector&lt;mpl_::integral_c&lt;int64_t, 2147483647&gt;&gt;, is_same&lt;true&gt; &gt;::************' test.h:153: error: ************mpl::equal&lt;mpl::vector_c&lt;int64_t, -0x00000000080000000l, 2147483647l, ...&gt;, mpl::vector&lt;mpl_::integral_c&lt;int64_t, 2147483648ll&gt;&gt;, is_same&lt;true&gt; &gt;::************' </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3342 Trac 1.4.3