c++ - boost::multiprecision cast from integer to cpp_dec_float compile error -


i encounter problem moving code server.

a minimal working example of problem following code (filename mp2.cpp):

#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_dec_float.hpp> #include <iostream>  using namespace std; using namespace boost::multiprecision;  int main() {     uint128_t = 1;     uint128_t b = 2;     cpp_dec_float_50 fa = static_cast<cpp_dec_float_50>(a);     cpp_dec_float_50 fb = static_cast<cpp_dec_float_50>(b);     cout << fa / fb << endl;     return 0; } 

compiles , works expected, writing 0.5 on standard output on dev machine (g++ 4.6.3, boost 1.55, 32 bits cpu).

for same code, g++ fails compiling on server error:

in file included /usr/local/include/boost/multiprecision/number.hpp:22:0,                  /usr/local/include/boost/multiprecision/cpp_int.hpp:12,                  mp2.cpp:1: /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp: in instantiation of 'void boost::multiprecision::detail::generic_interconvert(to&, const from&, const mpl_::int_<1>&, const mpl_::int_<0>&) [with = boost::multiprecision::backends::cpp_dec_float<50u>; = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>]': /usr/local/include/boost/multiprecision/number.hpp:108:7:   required 'boost::multiprecision::number<backend, expressiontemplates>::number(const boost::multiprecision::number<other, et>&, typename boost::enable_if_c<(! boost::multiprecision::detail::is_explicitly_convertible<other, backend>::value)>::type*) [with other = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u; backend = boost::multiprecision::backends::cpp_dec_float<50u>; boost::multiprecision::expression_template_option expressiontemplates = (boost::multiprecision::expression_template_option)1u; typename boost::enable_if_c<(! boost::multiprecision::detail::is_explicitly_convertible<other, backend>::value)>::type = void]' mp2.cpp:11:55:   required here /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp:43:4: error: no matching function call 'eval_is_zero(boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>&)' /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp:43:4: note: candidates are: in file included mp2.cpp:2:0: /usr/local/include/boost/multiprecision/cpp_dec_float.hpp:2905:13: note: template<unsigned int digits10, class exponenttype, class allocator> bool boost::multiprecision::backends::eval_is_zero(const boost::multiprecision::backends::cpp_dec_float<digits10, exponenttype, allocator>&) /usr/local/include/boost/multiprecision/cpp_dec_float.hpp:2905:13: note:   template argument deduction/substitution failed: in file included /usr/local/include/boost/multiprecision/number.hpp:22:0,                  /usr/local/include/boost/multiprecision/cpp_int.hpp:12,                  mp2.cpp:1: /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp:43:4: note:   'boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>' not derived 'const boost::multiprecision::backends::cpp_dec_float<digits10, exponenttype, allocator>' in file included /usr/local/include/boost/multiprecision/cpp_int.hpp:1787:0,                  mp2.cpp:1: /usr/local/include/boost/multiprecision/cpp_int/misc.hpp:94:4: note: template<unsigned int minbits1, unsigned int maxbits1, boost::multiprecision::cpp_integer_type signtype1, boost::multiprecision::cpp_int_check_type checked1, class allocator1> typename boost::enable_if_c<(! boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<minbits, maxbits, signtype, checked, allocator> >::value), bool>::type boost::multiprecision::backends::eval_is_zero(const boost::multiprecision::backends::cpp_int_backend<minbits, maxbits, signtype, checked, allocator>&) /usr/local/include/boost/multiprecision/cpp_int/misc.hpp:94:4: note:   template argument deduction/substitution failed: /usr/local/include/boost/multiprecision/cpp_int/misc.hpp: in substitution of 'template<unsigned int minbits1, unsigned int maxbits1, boost::multiprecision::cpp_integer_type signtype1, boost::multiprecision::cpp_int_check_type checked1, class allocator1> typename boost::enable_if_c<(! boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<minbits, maxbits, signtype, checked, allocator> >::value), bool>::type boost::multiprecision::backends::eval_is_zero(const boost::multiprecision::backends::cpp_int_backend<minbits, maxbits, signtype, checked, allocator>&) [with unsigned int minbits1 = 128u; unsigned int maxbits1 = 128u; boost::multiprecision::cpp_integer_type signtype1 = (boost::multiprecision::cpp_integer_type)0u; boost::multiprecision::cpp_int_check_type checked1 = (boost::multiprecision::cpp_int_check_type)0u; allocator1 = void]': /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp:43:4:   required 'void boost::multiprecision::detail::generic_interconvert(to&, const from&, const mpl_::int_<1>&, const mpl_::int_<0>&) [with = boost::multiprecision::backends::cpp_dec_float<50u>; = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>]' /usr/local/include/boost/multiprecision/number.hpp:108:7:   required 'boost::multiprecision::number<backend, expressiontemplates>::number(const boost::multiprecision::number<other, et>&, typename boost::enable_if_c<(! boost::multiprecision::detail::is_explicitly_convertible<other, backend>::value)>::type*) [with other = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u; backend = boost::multiprecision::backends::cpp_dec_float<50u>; boost::multiprecision::expression_template_option expressiontemplates = (boost::multiprecision::expression_template_option)1u; typename boost::enable_if_c<(! boost::multiprecision::detail::is_explicitly_convertible<other, backend>::value)>::type = void]' mp2.cpp:11:55:   required here /usr/local/include/boost/multiprecision/cpp_int/misc.hpp:94:4: error: no type named 'type' in 'struct boost::enable_if_c<false, bool>' in file included /usr/local/include/boost/multiprecision/cpp_int.hpp:18:0,                  mp2.cpp:1: /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp: in instantiation of 'void boost::multiprecision::detail::generic_interconvert(to&, const from&, const mpl_::int_<1>&, const mpl_::int_<0>&) [with = boost::multiprecision::backends::cpp_dec_float<50u>; = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>]': /usr/local/include/boost/multiprecision/number.hpp:108:7:   required 'boost::multiprecision::number<backend, expressiontemplates>::number(const boost::multiprecision::number<other, et>&, typename boost::enable_if_c<(! boost::multiprecision::detail::is_explicitly_convertible<other, backend>::value)>::type*) [with other = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u; backend = boost::multiprecision::backends::cpp_dec_float<50u>; boost::multiprecision::expression_template_option expressiontemplates = (boost::multiprecision::expression_template_option)1u; typename boost::enable_if_c<(! boost::multiprecision::detail::is_explicitly_convertible<other, backend>::value)>::type = void]' mp2.cpp:11:55:   required here /usr/local/include/boost/multiprecision/rational_adaptor.hpp:252:13: note: template<class intbackend> bool boost::multiprecision::backends::eval_is_zero(const boost::multiprecision::backends::rational_adaptor<intbackend>&) /usr/local/include/boost/multiprecision/rational_adaptor.hpp:252:13: note:   template argument deduction/substitution failed: in file included /usr/local/include/boost/multiprecision/number.hpp:22:0,                  /usr/local/include/boost/multiprecision/cpp_int.hpp:12,                  mp2.cpp:1: /usr/local/include/boost/multiprecision/detail/generic_interconvert.hpp:43:4: note:   'boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)0u, (boost::multiprecision::cpp_int_check_type)0u, void>' not derived 'const boost::multiprecision::backends::rational_adaptor<intbackend>' 

the server runs g++ 4.7.2 , boost 1.56, on 64 bits cpu. have installed same g++ , boost version see if issue, not.

from experimenting source, problems arise whenever try cast integers float. however, mentionned in documentation, proper way this.

does know how problem is, , how fix it?

i don't know library, seems problem comes bug (?) x86-64 architecture.

it should noted :

  1. i have same issue 64 bits os (linux mint 16 - g++ 4.8.1 - boost 1.53).
  2. as workaround, can cross-compile code 32 bits binary -m32 flag (tested success).
  3. the issue disappears using cpp_int intead of uint128_t.
  4. strangely, there no compilation errors using following custom type:

    typedef number<cpp_int_backend<128, 128, signed_magnitude, unchecked, std::allocator<limb_type> > > t128_custom; 

    problems appear when allocator replaced void (as defined uint128_t), or when usigned_magnitude used.

maybe should contact boost community further informations.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -