Boost C++ Libraries: Ticket #12777: uniform_real_distribution fails to compile with result_type having explicit conversion constructor from float https://svn.boost.org/trac10/ticket/12777 <p> Consider the following test program: </p> <pre class="wiki">#include &lt;random&gt; #include &lt;boost/random/uniform_real_distribution.hpp&gt; #include &lt;half.hpp&gt; template&lt;typename Float&gt; void test() { std::random_device rd; std::mt19937 mt(rd()); boost::random::uniform_real_distribution&lt;Float&gt; rnd(Float(1),Float(10)); rnd(mt); } int main() { test&lt;float&gt;(); // this works test&lt;half_float::half&gt;(); // and this doesn't compile } </pre><p> It uses half.hpp from half.sourceforge.net. This type has a peculiar behavior with arithmetic involving types other than it: the variable converts implicitly to <code>float</code>, and then the explicit constructor half_float::half(float) prevents some code from compiling. Namely, the code above doesn't compile due to the <code>return 2 * generate_uniform_real(...)</code> in generate_uniform_real(). I've seen there already exist explicit casts like for the arguments T(min_value / 2) and the like. I've been able to fix it locally with the attached patch. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12777 Trac 1.4.3 b7.10110111@… Sun, 22 Jan 2017 07:47:44 GMT attachment set https://svn.boost.org/trac10/ticket/12777 https://svn.boost.org/trac10/ticket/12777 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">uniform-random-real.patch</span> </li> </ul> <p> Proposed patch </p> Ticket