Boost C++ Libraries: Ticket #11764: boost/multiprecision/number.hpp:52:17: error: no viable overloaded '=' https://svn.boost.org/trac10/ticket/11764 <h1 class="section" id="Summary">Summary</h1> <p> The following simple program attempts to make use of simple features in Boost Multiprecision and Math. I have no problem using <code>constants::pi</code> with double, extended double, quad precision, or even a user-defined version of double double precision. However, when I try to get a single precision version of this constant, it fails. </p> <h1 class="section" id="SourceCode">Source Code</h1> <pre class="wiki">#include &lt;iostream&gt; #include &lt;utility&gt; #include &lt;boost/math/constants/constants.hpp&gt; #include &lt;boost/multiprecision/cpp_bin_float.hpp&gt; using boost::multiprecision::cpp_bin_float_single; using boost::multiprecision::cpp_bin_float_double; typedef boost::multiprecision::cpp_bin_float_single f32; typedef boost::multiprecision::cpp_bin_float_double f64; int main(void) { #if BUGTEST_PRECISION == 32 //f32 pi32 = boost::math::constants::pi&lt;f32, boost::math::policies::policy&lt;boost::math::policies::digits2&lt;32&gt; &gt; &gt;(); f32 pi32 = boost::math::constants::pi&lt;f32&gt;(); std::cout &lt;&lt; pi32 &lt;&lt; std::endl; #elif BUGTEST_PRECISION == 64 //f64 pi64 = boost::math::constants::pi&lt;f64, boost::math::policies::policy&lt;boost::math::policies::digits2&lt;64&gt; &gt; &gt;(); f64 pi64 = boost::math::constants::pi&lt;f64&gt;(); std::cout &lt;&lt; pi64 &lt;&lt; std::endl; #else #error Set BUGTEST_PRECISION to 32 or 64. #endif return 0; } </pre><h1 class="section" id="CompilersTested">Compilers Tested</h1> <p> Mac Yosemite (10.10.5): </p> <ul><li>Apple LLVM version 7.0.0 (<code>clang++</code>) </li><li>Clang 3.6.2 from Homebrew </li><li>GCC 4.2.1 ({g++}) </li><li>GCC 5.2.0 from Homebrew </li><li>Intel 16.0.0 </li></ul><h1 class="section" id="RepresentativeOutput">Representative Output</h1> <p> Clang and GCC show nearly identical errors. The Intel one is much shorter but seemingly equivalent. </p> <pre class="wiki">jrhammon-mac01:boost jrhammon$ clang++ -g -Wall -std=c++11 -stdlib=libc++ -DBUGTEST_PRECISION=64 bug.cc -o bug.x jrhammon-mac01:boost jrhammon$ clang++ -g -Wall -std=c++11 -stdlib=libc++ -DBUGTEST_PRECISION=32 bug.cc -o bug.x In file included from bug.cc:5: In file included from /usr/local/include/boost/multiprecision/cpp_bin_float.hpp:9: In file included from /usr/local/include/boost/multiprecision/cpp_int.hpp:12: /usr/local/include/boost/multiprecision/number.hpp:52:17: error: no viable overloaded '=' m_backend = canonical_value(v); ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~ /usr/local/include/boost/math/constants/constants.hpp:289:3: note: in instantiation of function template specialization 'boost::multiprecision::number&lt;boost::multiprecision::backends::cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt;, boost::multiprecision::expression_template_option::et_off&gt;::number&lt;float&gt;' requested here BOOST_DEFINE_MATH_CONSTANT(pi, 3.141592653589793238462643383279502884e+00, "3.141592653589793238462643383279502884197169... ^ /usr/local/include/boost/math/constants/constants.hpp:246:13: note: expanded from macro 'BOOST_DEFINE_MATH_CONSTANT' { return BOOST_JOIN(x, F); }\ ^ /usr/local/include/boost/config/suffix.hpp:544:28: note: expanded from macro 'BOOST_JOIN' #define BOOST_JOIN( X, Y ) BOOST_DO_JOIN( X, Y ) ^ /usr/local/include/boost/config/suffix.hpp:545:31: note: expanded from macro 'BOOST_DO_JOIN' #define BOOST_DO_JOIN( X, Y ) BOOST_DO_JOIN2(X,Y) ^ /usr/local/include/boost/config/suffix.hpp:546:32: note: expanded from macro 'BOOST_DO_JOIN2' #define BOOST_DO_JOIN2( X, Y ) X##Y ^ &lt;scratch space&gt;:14:1: note: expanded from here 3.141592653589793238462643383279502884e+00F ^ /usr/local/include/boost/multiprecision/cpp_bin_float.hpp:107:19: note: candidate function not viable: no known conversion from 'typename boost::disable_if&lt;is_same&lt;typename detail::canonical&lt;float, cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt; &gt;::type, float&gt;, typename detail::canonical&lt;float, cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt; &gt;::type&gt;::type' (aka 'double') to 'const boost::multiprecision::backends::cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt;' for 1st argument cpp_bin_float&amp; operator=(const cpp_bin_float &amp;o) BOOST_NOEXCEPT_IF(noexcept(std::declval&lt;rep_type&amp;&gt;() = std::declval&lt;co... ^ /usr/local/include/boost/multiprecision/cpp_bin_float.hpp:303:19: note: candidate function not viable: no known conversion from 'typename boost::disable_if&lt;is_same&lt;typename detail::canonical&lt;float, cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt; &gt;::type, float&gt;, typename detail::canonical&lt;float, cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt; &gt;::type&gt;::type' (aka 'double') to 'const char *' for 1st argument cpp_bin_float&amp; operator=(const char *s); ^ /usr/local/include/boost/multiprecision/cpp_bin_float.hpp:116:19: note: candidate template ignored: could not match 'cpp_bin_float&lt;Digits, DigitBase, type-parameter-0-2, type-parameter-0-3, MinExponent, MaxExponent&gt;' against 'double' cpp_bin_float&amp; operator=(const cpp_bin_float&lt;D, B, A, E, MinE, MaxE&gt; &amp;o) ^ /usr/local/include/boost/multiprecision/cpp_bin_float.hpp:129:74: note: candidate template ignored: substitution failure [with Float = double]: no type named 'type' in 'boost::enable_if_c&lt;false, boost::multiprecision::backends::cpp_bin_float&lt;24, boost::multiprecision::backends::digit_base_type::digit_base_2, void, short, -126, 127&gt; &amp;&gt;' &amp;&amp; (std::numeric_limits&lt;Float&gt;::radix == 2), cpp_bin_float&amp;&gt;::type operator=(const Float&amp; f) ~~~~ ^ /usr/local/include/boost/multiprecision/cpp_bin_float.hpp:271:30: note: candidate template ignored: disabled by 'enable_if' [with I = double] typename boost::enable_if&lt;is_integral&lt;I&gt;, cpp_bin_float&amp;&gt;::type operator=(const I&amp; i) ^ 1 error generated. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11764 Trac 1.4.3 Jeff Hammond <jeff.science@…> Tue, 27 Oct 2015 17:14:12 GMT attachment set https://svn.boost.org/trac10/ticket/11764 https://svn.boost.org/trac10/ticket/11764 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bug.cc</span> </li> </ul> <p> source file that fails </p> Ticket Jeff Hammond <jeff.science@…> Tue, 27 Oct 2015 17:14:48 GMT attachment set https://svn.boost.org/trac10/ticket/11764 https://svn.boost.org/trac10/ticket/11764 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clang.log</span> </li> </ul> <p> log of failed build with Clang </p> Ticket Jeff Hammond <jeff.science@…> Tue, 27 Oct 2015 17:15:04 GMT attachment set https://svn.boost.org/trac10/ticket/11764 https://svn.boost.org/trac10/ticket/11764 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clang36.log</span> </li> </ul> <p> log of failed build with Clang 3.6 </p> Ticket Jeff Hammond <jeff.science@…> Tue, 27 Oct 2015 17:15:24 GMT attachment set https://svn.boost.org/trac10/ticket/11764 https://svn.boost.org/trac10/ticket/11764 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">icpc.log</span> </li> </ul> <p> log of failed build with Intel </p> Ticket Jeff Hammond <jeff.science@…> Tue, 27 Oct 2015 17:15:42 GMT attachment set https://svn.boost.org/trac10/ticket/11764 https://svn.boost.org/trac10/ticket/11764 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gxx.log</span> </li> </ul> <p> log of failed build with GCC 4.2.1 </p> Ticket Jeff Hammond <jeff.science@…> Tue, 27 Oct 2015 17:16:02 GMT attachment set https://svn.boost.org/trac10/ticket/11764 https://svn.boost.org/trac10/ticket/11764 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gxx5.log</span> </li> </ul> <p> log of failed build with GCC 5.2.0 </p> Ticket John Maddock Thu, 29 Oct 2015 09:59:57 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11764#comment:1 https://svn.boost.org/trac10/ticket/11764#comment:1 <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> Thanks for the report, looks like I got the conversions and what is and is not permitted slightly wrong. Fixed in <a class="ext-link" href="https://github.com/boostorg/multiprecision/commit/7dfea115f8ddd78ef19a1d60bff04ecc93df7253"><span class="icon">​</span>https://github.com/boostorg/multiprecision/commit/7dfea115f8ddd78ef19a1d60bff04ecc93df7253</a> </p> Ticket