Opened 9 years ago

Closed 9 years ago

#8996 closed Feature Requests (wontfix)

Boost.Multiprecision - implicit conversion of reminder to divisor type.

Reported by: anonymous Owned by: John Maddock
Milestone: To Be Determined Component: multiprecision
Version: Boost 1.54.0 Severity: Cosmetic
Keywords: Cc:

Description

#include <boost/multiprecision/cpp_int.hpp>
#include <cstdint>
void test()
{
    typedef boost::multiprecision::cpp_int Num;
    typedef std::uint32_t Div;
    Num n(123);
    Div d(13);
    //Div r = n % d; // error: no implicit conversion
    Num rn = n % d; // this works...
    Div r = rn.convert_to< Div >(); // but explicit conversion is required
}

Change History (1)

comment:1 by John Maddock, 9 years ago

Resolution: wontfix
Status: newclosed

This is what the integer modulus function is for http://www.boost.org/doc/libs/1_54_0/libs/multiprecision/doc/html/boost_multiprecision/ref/number.html#boost_multiprecision.ref.number.integer_functions

#include <boost/multiprecision/cpp_int.hpp>
#include <cstdint>
void test()
{
    typedef boost::multiprecision::cpp_int Num;
    typedef std::uint32_t Div;
    Num n(123);
    Div d(13);
    Div r = integer_modulus(n, d);
}
Note: See TracTickets for help on using tickets.