As shown in the Boost Multiprecision documentation , converting from boost::multiprecision::cpp_intto boost::multiprecision::cpp_dec_float:
// Some interconversions between number types are completely generic,
// and are always available, albeit the conversions are always explicit:
cpp_int cppi(2);
cpp_dec_float_50 df(cppi); // OK, int to float // <-- But fails with cpp_dec_float<0>!
The ability to convert from cpp_intto a fixed-point floating-point type (i.e. a cpp_dec_float_50) gives hope that it would be possible to convert from a cpp_intto arbitrary width - the type of point in the library, i.e. a cpp_dec_float<0>. However, this does not work; the conversion failed for me in Visual Studio 2013, as shown in the following simple sample program:
#include <boost/multiprecision/number.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
int main()
{
boost::multiprecision::cpp_int n{ 0 };
boost::multiprecision::cpp_dec_float<0> f{ n }; // Compile error in MSVC 2013
}
cpp_dec_float_50, , , , : cpp_dec_float<0>.
Boost <boost/multiprecision/detail/default_ops.hpp>:
template <class R, class T>
inline bool check_in_range(const T& t)
{
// Can t fit in an R?
if(std::numeric_limits<R>::is_specialized && std::numeric_limits<R>::is_bounded
&& (t > (std::numeric_limits<R>::max)()))
return true;
return false;
}
:
C2784: "Enable_if:: result_type, :: :: result_type > BOOL > :: boost:: multiprecision:: operator > (const :: multiprecision:: :: & ;, Const boost:: multiprecision:: detail:: expression &) ': 'const boost:: multiprecision:: detail:: & ' from 'const next_type'
a boost::multiprecision::cpp_int boost::multiprecision::cpp_dec_float<0> ( , cpp_dec_float_50)?
( , , , , .)
!