Boost C++ Libraries: Ticket #10182: Header order dependency for boost/multiprecision/random.hpp https://svn.boost.org/trac10/ticket/10182 <p> Using boost/multiprecision/random.hpp requires that it gets included before boost/random/uniform_int_distribution.hpp when using it in combination with that.<br /> See example code: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;gmp.h&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;cstdlib&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multiprecision/gmp.hpp&gt;</span><span class="cp"></span> <span class="c1">//#include &lt;boost/multiprecision/random.hpp&gt; // fails unless this header is included first</span> <span class="cp">#include</span> <span class="cpf">&lt;boost/random/random_device.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/random/uniform_int_distribution.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/multiprecision/random.hpp&gt; // does not work if included here</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">boost</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">multiprecision</span><span class="o">::</span><span class="n">number</span><span class="o">&lt;</span><span class="n">multiprecision</span><span class="o">::</span><span class="n">gmp_int</span><span class="o">&gt;</span> <span class="n">MpzInt</span><span class="p">;</span> <span class="n">random</span><span class="o">::</span><span class="n">random_device</span> <span class="n">rndDevice</span><span class="p">;</span> <span class="n">MpzInt</span> <span class="n">rndRangeTo</span><span class="p">(</span><span class="n">MpzInt</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="o">&lt;&lt;</span> <span class="mi">256</span><span class="p">);</span> <span class="k">const</span> <span class="n">MpzInt</span> <span class="n">rndRangeFrom</span><span class="p">(</span><span class="n">rndRangeTo</span> <span class="o">&gt;&gt;</span> <span class="mi">1</span><span class="p">);</span> <span class="n">random</span><span class="o">::</span><span class="n">uniform_int_distribution</span><span class="o">&lt;</span><span class="n">MpzInt</span><span class="o">&gt;</span> <span class="n">rndRange</span><span class="p">(</span><span class="n">rndRangeFrom</span><span class="p">,</span> <span class="n">rndRangeTo</span><span class="p">);</span> <span class="k">const</span> <span class="n">MpzInt</span> <span class="n">rndValue</span><span class="p">(</span><span class="n">rndRange</span><span class="p">(</span><span class="n">rndDevice</span><span class="p">));</span> <span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">rndValue</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="n">EXIT_SUCCESS</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10182 Trac 1.4.3 gfurnish Mon, 07 Jul 2014 18:31:25 GMT <link>https://svn.boost.org/trac10/ticket/10182#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10182#comment:1</guid> <description> <p> Per some irc discussions I have been encouraged to post that I tested this on latest master 80b9d8d13617c487c5ebaf06fb8ba757a91e6a0c with gcc version 4.8.3 20140624 (Red Hat 4.8.3-1) and can confirm. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 28 Mar 2015 16:36:31 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10182#comment:2 https://svn.boost.org/trac10/ticket/10182#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> This is actually a known limitation. However, the latest develop code for Boost.Multiprecision plus Boost.Random removes the need for boost/multiprecision/random.hpp altergether and fixes this issue. Unfortunately this code is too late for the next (1.59) release. </p> Ticket