10 #if !defined(SG14_MULTIPRECISION_H) 11 #define SG14_MULTIPRECISION_H 1 13 #include <sg14/num_traits.h> 15 #include <boost/multiprecision/cpp_int.hpp> 19 namespace _bmp = boost::multiprecision;
28 template<
unsigned NumBits, _bmp::cpp_
integer_type SignType, _bmp::cpp_
int_check_type Checked,
class Allocator>
29 struct make_signed<_bmp::cpp_int_backend<NumBits, NumBits, SignType, Checked, Allocator>> {
30 using type = _bmp::cpp_int_backend<NumBits, NumBits, _bmp::signed_magnitude, Checked, Allocator>;
33 template<
unsigned NumBits, _bmp::cpp_
integer_type SignType, _bmp::cpp_
int_check_type Checked,
class Allocator>
34 struct make_unsigned<_bmp::cpp_int_backend<NumBits, NumBits, SignType, Checked, Allocator>> {
35 using type = _bmp::cpp_int_backend<NumBits, NumBits, _bmp::unsigned_magnitude, Checked, Allocator>;
38 template<
unsigned NumBits, _bmp::cpp_
integer_type SignType, _bmp::cpp_
int_check_type Checked,
class Allocator>
39 struct digits<_bmp::cpp_int_backend<NumBits, NumBits, SignType, Checked, Allocator>>
40 : std::integral_constant<_digits_type, NumBits> {
43 template<
unsigned NumBits, _bmp::cpp_
integer_type SignType, _bmp::cpp_
int_check_type Checked,
class Allocator, _digits_type MinNumDigits>
44 struct set_digits<_bmp::cpp_int_backend<NumBits, NumBits, SignType, Checked, Allocator>, MinNumDigits> {
45 static constexpr
unsigned width = MinNumDigits + (SignType == _bmp::signed_magnitude);
46 using type = _bmp::cpp_int_backend<width, width, SignType, Checked, Allocator>;
49 template<
class Backend, _bmp::expression_
template_option ExpressionTemplates>
50 struct make_signed<_bmp::number<Backend, ExpressionTemplates>> {
51 using type = _bmp::number<make_signed_t<Backend>, ExpressionTemplates>;
54 template<
class Backend, _bmp::expression_
template_option ExpressionTemplates>
55 struct make_unsigned<_bmp::number<Backend, ExpressionTemplates>> {
56 using type = _bmp::number<make_unsigned_t<Backend>, ExpressionTemplates>;
59 template<
class Backend, _bmp::expression_
template_option ExpressionTemplates>
60 struct digits<_bmp::number<Backend, ExpressionTemplates>>
64 template<
class Backend, _bmp::expression_
template_option ExpressionTemplates, _digits_type MinNumDigits>
65 struct set_digits<_bmp::number<Backend, ExpressionTemplates>, MinNumDigits> {
66 using type = _bmp::number<set_digits_t<Backend, MinNumDigits>, ExpressionTemplates>;
73 namespace _sized_integer_impl {
74 template<
unsigned NumBits, _bmp::cpp_
integer_type SignType>
75 using backend = _bmp::cpp_int_backend<
76 NumBits, NumBits, SignType, _bmp::unchecked,
void>;
80 template<unsigned NumDigits = digits<int>::value>
81 using signed_multiprecision = _bmp::number<_sized_integer_impl::backend<NumDigits+1, _bmp::signed_magnitude>, _bmp::et_off>;
84 template<unsigned NumDigits = digits<unsigned>::value>
85 using unsigned_multiprecision = _bmp::number<_sized_integer_impl::backend<NumDigits, _bmp::unsigned_magnitude>, _bmp::et_off>;
88 template<unsigned NumDigits = digits<int>::value>
89 using multiprecision = signed_multiprecision<NumDigits+1>;
92 #endif // SG14_MULTIPRECISION_H study group 14 of the C++ working group
Definition: const_integer.h:22