[Boost-bugs] [Boost C++ Libraries] #13577: rational_adaptor does not compile with fixed width cpp_int

Subject: [Boost-bugs] [Boost C++ Libraries] #13577: rational_adaptor does not compile with fixed width cpp_int
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-05-28 22:46:56


#13577: rational_adaptor does not compile with fixed width cpp_int
------------------------------+----------------------------
 Reporter: jgarber1@… | Owner: John Maddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
  Version: Boost 1.67.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------------
 Hello, I am trying to use the `rational_adaptor` class with a 128-bit
 `cpp_int` as a fixed-width alternative to `cpp_rational`. However,
 attempting to do so results in a compiler error.

 {{{
 #include <boost/multiprecision/cpp_int.hpp>

 using namespace boost::multiprecision;

 using Rational = number<rational_adaptor<cpp_int_backend<128, 128,
 signed_magnitude, checked, void>>>;

 int main() {
     Rational x = 3;
     x /= 2;
 }
 }}}

 Compiling this program (Clang, Mac 10.12, Boost 1.67) results in the
 following error

 {{{
 /usr/local/include/boost/multiprecision/rational_adaptor.hpp:268:11:
 error: no matching function for call to
       'eval_is_zero'
    return eval_is_zero(val.data().numerator().backend());
           ^~~~~~~~~~~~
 /usr/local/include/boost/multiprecision/rational_adaptor.hpp:230:7: note:
 in instantiation of function template
       specialization
 'boost::multiprecision::backends::eval_is_zero<boost::multiprecision::backends::cpp_int_backend<128,
 128,
       boost::multiprecision::cpp_integer_type::signed_magnitude,
 boost::multiprecision::cpp_int_check_type::checked,
       void> >' requested here
    if(eval_is_zero(o))
       ^
 /usr/local/include/boost/multiprecision/detail/default_ops.hpp:154:4:
 note: in instantiation of function template
       specialization
 'boost::multiprecision::backends::eval_divide<boost::multiprecision::backends::cpp_int_backend<128,
       128, boost::multiprecision::cpp_integer_type::signed_magnitude,
       boost::multiprecision::cpp_int_check_type::checked, void> >'
 requested here
    eval_divide(result, t);
    ^
 /usr/local/include/boost/multiprecision/number.hpp:447:7: note: in
 instantiation of function template specialization
 'boost::multiprecision::default_ops::eval_divide<boost::multiprecision::backends::rational_adaptor<boost::multiprecision::backends::cpp_int_backend<128,
       128, boost::multiprecision::cpp_integer_type::signed_magnitude,
       boost::multiprecision::cpp_int_check_type::checked, void> >, int>'
 requested here
       eval_divide(m_backend, canonical_value(v));
       ^
 bug2.cpp:9:7: note: in instantiation of function template specialization
 'boost::multiprecision::number<boost::multiprecision::backends::rational_adaptor<boost::multiprecision::backends::cpp_int_backend<128,
       128, boost::multiprecision::cpp_integer_type::signed_magnitude,
       boost::multiprecision::cpp_int_check_type::checked, void> >,
 boost::multiprecision::expression_template_option::et_off>::operator/=<int>'
 requested here
     x /= 2;
       ^
 /usr/local/include/boost/multiprecision/rational_adaptor.hpp:266:13: note:
 candidate template ignored: could not match
       'rational_adaptor' against 'cpp_int_backend'
 inline bool eval_is_zero(const rational_adaptor<IntBackend>& val)
             ^
 /usr/local/include/boost/multiprecision/cpp_int/misc.hpp:155:4: note:
 candidate template ignored: substitution failure
       [with MinBits1 = 128, MaxBits1 = 128, SignType1 =
 boost::multiprecision::cpp_integer_type::signed_magnitude,
       Checked1 = boost::multiprecision::cpp_int_check_type::checked,
 Allocator1 = void]: no type named 'type' in
       'boost::enable_if_c<false, bool>'
    eval_is_zero(const cpp_int_backend<MinBits1, MaxBits1, SignType1,
 Checked1, Allocator1>& val) BOOST_NOEXCEPT
    ^
 1 error generated.
 }}}

 Is the `rational_adaptor` class intended for use with fixed-width
 integers, or just arbitrary precision ones?

 Thank you

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/13577>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-05-28 22:51:57 UTC