Completely remove MPL usage.

This commit is contained in:
jzmaddock
2021-01-16 11:22:28 +00:00
parent 5d4926d002
commit a9b4361c0a
102 changed files with 845 additions and 818 deletions
+8 -8
View File
@@ -30,11 +30,11 @@ and `ff` is a variable of type `std::ios_base::fmtflags`.
[table Compulsory Requirements on the Backend type. [table Compulsory Requirements on the Backend type.
[[Expression][Return Type][Comments][Throws]] [[Expression][Return Type][Comments][Throws]]
[[`B::signed_types`][`mpl::list<type-list>`][A list of signed integral types that can be assigned to type B. The types shall be [[`B::signed_types`][`std::tuple<type-list>`][A list of signed integral types that can be assigned to type B. The types shall be
listed in order of size, smallest first, and shall terminate in the type that is `std::intmax_t`.][[space]]] listed in order of size, smallest first, and shall terminate in the type that is `std::intmax_t`.][[space]]]
[[`B::unsigned_types`][`mpl::list<type-list>`][A list of unsigned integral types that can be assigned to type B. The types shall be [[`B::unsigned_types`][`std::tuple<type-list>`][A list of unsigned integral types that can be assigned to type B. The types shall be
listed in order of size, smallest first, and shall terminate in the type that is `std::uintmax_t`.][[space]]] listed in order of size, smallest first, and shall terminate in the type that is `std::uintmax_t`.][[space]]]
[[`B::float_types`][`mpl::list<type-list>`][A list of floating-point types that can be assigned to type B.The types shall be [[`B::float_types`][`std::tuple<type-list>`][A list of floating-point types that can be assigned to type B.The types shall be
listed in order of size, smallest first, and shall terminate in type `long double`.][[space]]] listed in order of size, smallest first, and shall terminate in type `long double`.][[space]]]
[[`B::exponent_type`][A signed integral type.][The type of the exponent of type B. This type is required only for floating-point types.][[space]]] [[`B::exponent_type`][A signed integral type.][The type of the exponent of type B. This type is required only for floating-point types.][[space]]]
[[`B()`][ ][Default constructor.][[space]]] [[`B()`][ ][Default constructor.][[space]]]
@@ -77,7 +77,7 @@ and `ff` is a variable of type `std::ios_base::fmtflags`.
[[`eval_floor(b, cb)`][`void`][Stores the floor of `cb` in `b`, only required when `B` is a floating-point type.][[space]]] [[`eval_floor(b, cb)`][`void`][Stores the floor of `cb` in `b`, only required when `B` is a floating-point type.][[space]]]
[[`eval_ceil(b, cb)`][`void`][Stores the ceiling of `cb` in `b`, only required when `B` is a floating-point type.][[space]]] [[`eval_ceil(b, cb)`][`void`][Stores the ceiling of `cb` in `b`, only required when `B` is a floating-point type.][[space]]]
[[`eval_sqrt(b, cb)`][`void`][Stores the square root of `cb` in `b`, only required when `B` is a floating-point type.][[space]]] [[`eval_sqrt(b, cb)`][`void`][Stores the square root of `cb` in `b`, only required when `B` is a floating-point type.][[space]]]
[[`boost::multiprecision::number_category<B>::type`][`mpl::int_<N>`][`N` is one of the values `number_kind_integer`, `number_kind_floating_point`, `number_kind_complex`, `number_kind_rational` or `number_kind_fixed_point`. [[`boost::multiprecision::number_category<B>::type`][`std::integral_constant<int, N>`][`N` is one of the values `number_kind_integer`, `number_kind_floating_point`, `number_kind_complex`, `number_kind_rational` or `number_kind_fixed_point`.
Defaults to `number_kind_floating_point`.][[space]]] Defaults to `number_kind_floating_point`.][[space]]]
[[`eval_conj(b, cb)`][`void`][Sets `b` to the complex conjugate of `cb`. Required for complex types only - other types have a sensible default.][[space]]] [[`eval_conj(b, cb)`][`void`][Sets `b` to the complex conjugate of `cb`. Required for complex types only - other types have a sensible default.][[space]]]
[[`eval_proj(b, cb)`][`void`][Sets `b` to the Riemann projection of `cb`. Required for complex types only - other types have a sensible default.][[space]]] [[`eval_proj(b, cb)`][`void`][Sets `b` to the Riemann projection of `cb`. Required for complex types only - other types have a sensible default.][[space]]]
@@ -141,11 +141,11 @@ and `ff` is a variable of type `std::ios_base::fmtflags`.
When not provided, the default implementation returns `eval_lt(cb, a)`.][[space]]] When not provided, the default implementation returns `eval_lt(cb, a)`.][[space]]]
[[`eval_is_zero(cb)`][`bool`][Returns `true` if `cb` is zero, otherwise `false`. The default version of this function [[`eval_is_zero(cb)`][`bool`][Returns `true` if `cb` is zero, otherwise `false`. The default version of this function
returns `cb.compare(ui_type(0)) == 0`, where `ui_type` is `ui_type` is returns `cb.compare(ui_type(0)) == 0`, where `ui_type` is `ui_type` is
`typename mpl::front<typename B::unsigned_types>::type`.][[space]]] `typename std::tuple_element<0, typename B::unsigned_types>::type`.][[space]]]
[[`eval_get_sign(cb)`][`int`][Returns a value < zero if `cb` is negative, a value > zero if `cb` is positive, and zero if `cb` is zero. [[`eval_get_sign(cb)`][`int`][Returns a value < zero if `cb` is negative, a value > zero if `cb` is positive, and zero if `cb` is zero.
The default version of this function The default version of this function
returns `cb.compare(ui_type(0))`, where `ui_type` is `ui_type` is returns `cb.compare(ui_type(0))`, where `ui_type` is `ui_type` is
`typename mpl::front<typename B::unsigned_types>::type`.][[space]]] `typename std::tuple_element<0, typename B::unsigned_types>::type`.][[space]]]
[[['Basic arithmetic:]]] [[['Basic arithmetic:]]]
[[`eval_add(b, a)`][`void`][Adds `a` to `b`. The type of `a` shall be listed in one of the type lists [[`eval_add(b, a)`][`void`][Adds `a` to `b`. The type of `a` shall be listed in one of the type lists
@@ -234,10 +234,10 @@ and `ff` is a variable of type `std::ios_base::fmtflags`.
[`std::overflow_error` if cb has the value zero, and `std::numeric_limits<number<B> >::has_infinity == false`]] [`std::overflow_error` if cb has the value zero, and `std::numeric_limits<number<B> >::has_infinity == false`]]
[[`eval_increment(b)`][void][Increments the value of `b` by one. [[`eval_increment(b)`][void][Increments the value of `b` by one.
When not provided, does the equivalent of `eval_add(b, static_cast<ui_type>(1u))`. When not provided, does the equivalent of `eval_add(b, static_cast<ui_type>(1u))`.
Where `ui_type` is `typename mpl::front<typename B::unsigned_types>::type`.][[space]]] Where `ui_type` is `typename std::tuple_element<0, typename B::unsigned_types>::type`.][[space]]]
[[`eval_decrement(b)`][void][Decrements the value of `b` by one. [[`eval_decrement(b)`][void][Decrements the value of `b` by one.
When not provided, does the equivalent of `eval_subtract(b, static_cast<ui_type>(1u))`. When not provided, does the equivalent of `eval_subtract(b, static_cast<ui_type>(1u))`.
Where `ui_type` is `typename mpl::front<typename B::unsigned_types>::type`.][[space]]] Where `ui_type` is `typename std::tuple_element<0, typename B::unsigned_types>::type`.][[space]]]
[[['Integer specific operations:]]] [[['Integer specific operations:]]]
[[`eval_modulus(b, a)`][`void`][Computes `b %= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists [[`eval_modulus(b, a)`][`void`][Computes `b %= cb`, only required when `B` is an integer type. The type of `a` shall be listed in one of the type lists
+1 -1
View File
@@ -51,7 +51,7 @@ given the limitations of the type and our internal requirements".]]
given the limitations of the type and our internal requirements".]] given the limitations of the type and our internal requirements".]]
] ]
The type of `number_category<cpp_bin_float<Args...> >::type` is `mpl::int_<number_kind_floating_point>`. The type of `number_category<cpp_bin_float<Args...> >::type` is `std::integral_constant<int, number_kind_floating_point>`.
More information on this type can be found in the [link boost_multiprecision.tut.floats.cpp_bin_float tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.floats.cpp_bin_float tutorial].
+1 -1
View File
@@ -35,7 +35,7 @@ template argument should not be set too high or the class's size will grow unrea
allocation is performed, but can be set to a standard library allocator if dynamic allocation makes more sense.]] allocation is performed, but can be set to a standard library allocator if dynamic allocation makes more sense.]]
] ]
The type of `number_category<cpp_dec_float<Args...> >::type` is `mpl::int_<number_kind_floating_point>`. The type of `number_category<cpp_dec_float<Args...> >::type` is `std::integral_constant<int, number_kind_floating_point>`.
More information on this type can be found in the [link boost_multiprecision.tut.floats.cpp_dec_float tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.floats.cpp_dec_float tutorial].
+1 -1
View File
@@ -90,7 +90,7 @@ The template arguments are:
[[Allocator][The allocator to use for dynamic memory allocation, or type `void` if MaxBits == MinBits.]] [[Allocator][The allocator to use for dynamic memory allocation, or type `void` if MaxBits == MinBits.]]
] ]
The type of `number_category<cpp_int<Args...> >::type` is `mpl::int_<number_kind_integer>`. The type of `number_category<cpp_int<Args...> >::type` is `std::integral_constant<int, number_kind_integer>`.
More information on this type can be found in the [link boost_multiprecision.tut.ints.cpp_int tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.ints.cpp_int tutorial].
+1 -1
View File
@@ -33,7 +33,7 @@ and `number::precision`. Note that this type does not in any way change the GMP
it does not change the default precision of the mpf_t data type), therefore you can safely mix this type with existing it does not change the default precision of the mpf_t data type), therefore you can safely mix this type with existing
code that uses GMP, and also mix `gmp_float`s of differing precision. code that uses GMP, and also mix `gmp_float`s of differing precision.
The type of `number_category<cpp_int<Args...> >::type` is `mpl::int_<number_kind_floating_point>`. The type of `number_category<cpp_int<Args...> >::type` is `std::integral_constant<int, number_kind_floating_point>`.
More information on this type can be found in the [link boost_multiprecision.tut.floats.gmp_float tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.floats.gmp_float tutorial].
+1 -1
View File
@@ -22,7 +22,7 @@ Class template `gmp_int` fulfils all of the requirements for a [link boost_multi
Its members and non-member functions are deliberately not documented: these are considered implementation details that are subject Its members and non-member functions are deliberately not documented: these are considered implementation details that are subject
to change. to change.
The type of `number_category<cpp_int<Args...> >::type` is `mpl::int_<number_kind_integer>`. The type of `number_category<cpp_int<Args...> >::type` is `std::integral_constant<int, number_kind_integer>`.
More information on this type can be found in the [link boost_multiprecision.tut.ints.gmp_int tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.ints.gmp_int tutorial].
+1 -1
View File
@@ -50,7 +50,7 @@ authors of backend types should generally specialise one of the traits above, ra
template <class T> template <class T>
is_unsigned_number; is_unsigned_number;
These two traits inherit from either `mpl::true_` or `mpl::false_`, by default types are assumed to be signed unless These two traits inherit from either `std::integral_constant<bool, true>` or `std::integral_constant<bool, false>`, by default types are assumed to be signed unless
`is_unsigned_number` is specialized for that type. `is_unsigned_number` is specialized for that type.
[endsect] [endsect]
+1 -1
View File
@@ -33,7 +33,7 @@ and `number::precision`. Note that this type does not in any way change the GMP
it does not change the default precision of the mpfr_t data type), therefore you can safely mix this type with existing it does not change the default precision of the mpfr_t data type), therefore you can safely mix this type with existing
code that uses GMP or MPFR, and also mix `mpfr_float_backend`s of differing precision. code that uses GMP or MPFR, and also mix `mpfr_float_backend`s of differing precision.
The type of `number_category<cpp_int<Args...> >::type` is `mpl::int_<number_kind_floating_point>`. The type of `number_category<cpp_int<Args...> >::type` is `std::integral_constant<int, number_kind_floating_point>`.
More information on this type can be found in the [link boost_multiprecision.tut.floats.mpfr_float tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.floats.mpfr_float tutorial].
+3 -3
View File
@@ -694,7 +694,7 @@ If this is a type with multiple components (for example rational or complex type
template <class T> template <class T>
struct number_category; struct number_category;
A traits class that inherits from `mpl::int_<N>` where `N` is one of the enumerated values `number_kind_integer`, `number_kind_floating_point`, A traits class that inherits from `std::integral_constant<int, N>` where `N` is one of the enumerated values `number_kind_integer`, `number_kind_floating_point`,
`number_kind_rational`, `number_kind_fixed_point`, or `number_kind_unknown`. This traits class is specialized for any type that has `number_kind_rational`, `number_kind_fixed_point`, or `number_kind_unknown`. This traits class is specialized for any type that has
`std::numeric_limits` support as well as for classes in this library: which means it can be used for generic code that must work `std::numeric_limits` support as well as for classes in this library: which means it can be used for generic code that must work
with __fundamental arithmetic types as well as multiprecision ones. with __fundamental arithmetic types as well as multiprecision ones.
@@ -702,12 +702,12 @@ with __fundamental arithmetic types as well as multiprecision ones.
template <class T> template <class T>
struct is_number; struct is_number;
A traits class that inherits from `mpl::true_` if T is an instance of `number<>`, otherwise from `mpl::false_`. A traits class that inherits from `std::integral_constant<bool, true>` if T is an instance of `number<>`, otherwise from `std::integral_constant<bool, false>`.
template <class T> template <class T>
struct is_number_expression; struct is_number_expression;
A traits class that inherits from `mpl::true_` if T is an expression template type derived from `number<>`, otherwise from `mpl::false_`. A traits class that inherits from `std::integral_constant<bool, true>` if T is an expression template type derived from `number<>`, otherwise from `std::integral_constant<bool, false>`.
[h4 Integer functions] [h4 Integer functions]
+1 -1
View File
@@ -22,7 +22,7 @@ Class template `tommath_int` fulfils all of the requirements for a [link boost_m
Its members and non-member functions are deliberately not documented: these are considered implementation details that are subject Its members and non-member functions are deliberately not documented: these are considered implementation details that are subject
to change. to change.
The type of `number_category<cpp_int<Args...> >::type` is `mpl::int_<number_kind_integer>`. The type of `number_category<cpp_int<Args...> >::type` is `std::integral_constant<int, number_kind_integer>`.
More information on this type can be found in the [link boost_multiprecision.tut.ints.tom_int tutorial]. More information on this type can be found in the [link boost_multiprecision.tut.ints.tom_int tutorial].
@@ -88,7 +88,7 @@ struct complex_adaptor
template <class V> template <class V>
complex_adaptor& operator=(const V& v) complex_adaptor& operator=(const V& v)
{ {
typedef typename mpl::front<unsigned_types>::type ui_type; typedef typename std::tuple_element<0, unsigned_types>::type ui_type;
m_real = v; m_real = v;
m_imag = ui_type(0u); m_imag = ui_type(0u);
return *this; return *this;
@@ -102,7 +102,7 @@ struct complex_adaptor
} }
complex_adaptor& operator=(const char* s) complex_adaptor& operator=(const char* s)
{ {
typedef typename mpl::front<unsigned_types>::type ui_type; typedef typename std::tuple_element<0, unsigned_types>::type ui_type;
ui_type zero = 0u; ui_type zero = 0u;
using default_ops::eval_fpclassify; using default_ops::eval_fpclassify;
@@ -370,7 +370,7 @@ inline void eval_sqrt(complex_adaptor<Backend>& result, const complex_adaptor<Ba
if (eval_is_zero(val.imag_data()) && (eval_get_sign(val.real_data()) >= 0)) if (eval_is_zero(val.imag_data()) && (eval_get_sign(val.real_data()) >= 0))
{ {
static const typename mpl::front<typename Backend::unsigned_types>::type zero = 0u; static const typename std::tuple_element<0, typename Backend::unsigned_types>::type zero = 0u;
eval_sqrt(result.real_data(), val.real_data()); eval_sqrt(result.real_data(), val.real_data());
result.imag_data() = zero; result.imag_data() = zero;
return; return;
@@ -433,7 +433,7 @@ inline void eval_pow(complex_adaptor<Backend>& result, const complex_adaptor<Bac
if (eval_is_zero(e)) if (eval_is_zero(e))
{ {
typename mpl::front<typename Backend::unsigned_types>::type one(1); typename std::tuple_element<0, typename Backend::unsigned_types>::type one(1);
result = one; result = one;
return; return;
} }
@@ -449,7 +449,7 @@ inline void eval_pow(complex_adaptor<Backend>& result, const complex_adaptor<Bac
{ {
Backend n = std::numeric_limits<number<Backend> >::infinity().backend(); Backend n = std::numeric_limits<number<Backend> >::infinity().backend();
result.real_data() = n; result.real_data() = n;
typename mpl::front<typename Backend::unsigned_types>::type zero(0); typename std::tuple_element<0, typename Backend::unsigned_types>::type zero(0);
if (eval_is_zero(e.imag_data())) if (eval_is_zero(e.imag_data()))
result.imag_data() = zero; result.imag_data() = zero;
else else
@@ -457,7 +457,7 @@ inline void eval_pow(complex_adaptor<Backend>& result, const complex_adaptor<Bac
} }
else else
{ {
typename mpl::front<typename Backend::unsigned_types>::type zero(0); typename std::tuple_element<0, typename Backend::unsigned_types>::type zero(0);
result = zero; result = zero;
} }
return; return;
@@ -480,7 +480,7 @@ inline void eval_exp(complex_adaptor<Backend>& result, const complex_adaptor<Bac
if (eval_is_zero(arg.imag_data())) if (eval_is_zero(arg.imag_data()))
{ {
eval_exp(result.real_data(), arg.real_data()); eval_exp(result.real_data(), arg.real_data());
typename mpl::front<typename Backend::unsigned_types>::type zero(0); typename std::tuple_element<0, typename Backend::unsigned_types>::type zero(0);
result.imag_data() = zero; result.imag_data() = zero;
return; return;
} }
@@ -509,7 +509,7 @@ inline void eval_log(complex_adaptor<Backend>& result, const complex_adaptor<Bac
if (eval_is_zero(arg.imag_data()) && (eval_get_sign(arg.real_data()) >= 0)) if (eval_is_zero(arg.imag_data()) && (eval_get_sign(arg.real_data()) >= 0))
{ {
eval_log(result.real_data(), arg.real_data()); eval_log(result.real_data(), arg.real_data());
typename mpl::front<typename Backend::unsigned_types>::type zero(0); typename std::tuple_element<0, typename Backend::unsigned_types>::type zero(0);
result.imag_data() = zero; result.imag_data() = zero;
return; return;
} }
@@ -529,7 +529,7 @@ inline void eval_log10(complex_adaptor<Backend>& result, const complex_adaptor<B
using default_ops::eval_divide; using default_ops::eval_divide;
using default_ops::eval_log; using default_ops::eval_log;
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
Backend ten; Backend ten;
ten = ui_type(10); ten = ui_type(10);
@@ -587,7 +587,7 @@ void tanh_imp(const T& r, const T& i, T& r_result, T& i_result)
using default_ops::eval_fpclassify; using default_ops::eval_fpclassify;
using default_ops::eval_get_sign; using default_ops::eval_get_sign;
typedef typename boost::mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
ui_type one(1); ui_type one(1);
// //
// Set: // Set:
@@ -671,7 +671,7 @@ inline void eval_asin(complex_adaptor<Backend>& result, const complex_adaptor<Ba
template <class Backend> template <class Backend>
inline void eval_acos(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg) inline void eval_acos(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg)
{ {
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
using default_ops::eval_asin; using default_ops::eval_asin;
@@ -686,7 +686,7 @@ inline void eval_acos(complex_adaptor<Backend>& result, const complex_adaptor<Ba
template <class Backend> template <class Backend>
inline void eval_atan(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg) inline void eval_atan(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg)
{ {
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
ui_type one = (ui_type)1u; ui_type one = (ui_type)1u;
using default_ops::eval_add; using default_ops::eval_add;
@@ -751,7 +751,7 @@ inline void eval_cosh(complex_adaptor<Backend>& result, const complex_adaptor<Ba
template <class Backend> template <class Backend>
inline void eval_asinh(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg) inline void eval_asinh(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg)
{ {
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
ui_type one = (ui_type)1u; ui_type one = (ui_type)1u;
using default_ops::eval_add; using default_ops::eval_add;
@@ -769,7 +769,7 @@ inline void eval_asinh(complex_adaptor<Backend>& result, const complex_adaptor<B
template <class Backend> template <class Backend>
inline void eval_acosh(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg) inline void eval_acosh(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg)
{ {
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
ui_type one = (ui_type)1u; ui_type one = (ui_type)1u;
using default_ops::eval_add; using default_ops::eval_add;
@@ -794,7 +794,7 @@ inline void eval_acosh(complex_adaptor<Backend>& result, const complex_adaptor<B
template <class Backend> template <class Backend>
inline void eval_atanh(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg) inline void eval_atanh(complex_adaptor<Backend>& result, const complex_adaptor<Backend>& arg)
{ {
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
ui_type one = (ui_type)1u; ui_type one = (ui_type)1u;
using default_ops::eval_add; using default_ops::eval_add;
@@ -826,7 +826,7 @@ inline void eval_proj(complex_adaptor<Backend>& result, const complex_adaptor<Ba
{ {
using default_ops::eval_get_sign; using default_ops::eval_get_sign;
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
ui_type zero = (ui_type)0u; ui_type zero = (ui_type)0u;
int c1 = eval_fpclassify(arg.real_data()); int c1 = eval_fpclassify(arg.real_data());
@@ -890,7 +890,7 @@ inline std::size_t hash_value(const complex_adaptor<Backend>& val)
using boost::multiprecision::backends::complex_adaptor; using boost::multiprecision::backends::complex_adaptor;
template <class Backend> template <class Backend>
struct number_category<complex_adaptor<Backend> > : public boost::mpl::int_<boost::multiprecision::number_kind_complex> struct number_category<complex_adaptor<Backend> > : public std::integral_constant<int, boost::multiprecision::number_kind_complex>
{}; {};
template <class Backend, expression_template_option ExpressionTemplates> template <class Backend, expression_template_option ExpressionTemplates>
@@ -13,7 +13,6 @@
#include <cstdint> #include <cstdint>
#include <boost/multiprecision/number.hpp> #include <boost/multiprecision/number.hpp>
#include <boost/math/special_functions/fpclassify.hpp> #include <boost/math/special_functions/fpclassify.hpp>
#include <boost/mpl/list.hpp>
#include <boost/container_hash/hash.hpp> #include <boost/container_hash/hash.hpp>
namespace boost { namespace boost {
@@ -27,9 +26,9 @@ namespace concepts {
struct number_backend_float_architype struct number_backend_float_architype
{ {
typedef mpl::list<boost::long_long_type> signed_types; typedef std::tuple<boost::long_long_type> signed_types;
typedef mpl::list<boost::ulong_long_type> unsigned_types; typedef std::tuple<boost::ulong_long_type> unsigned_types;
typedef mpl::list<long double> float_types; typedef std::tuple<long double> float_types;
typedef int exponent_type; typedef int exponent_type;
number_backend_float_architype() number_backend_float_architype()
@@ -211,7 +210,7 @@ typedef boost::multiprecision::number<number_backend_float_architype> mp_number_
} // namespace concepts } // namespace concepts
template <> template <>
struct number_category<concepts::number_backend_float_architype> : public mpl::int_<number_kind_floating_point> struct number_category<concepts::number_backend_float_architype> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
}} // namespace boost::multiprecision }} // namespace boost::multiprecision
+10 -10
View File
@@ -92,7 +92,7 @@ class cpp_bin_float
typedef typename rep_type::signed_types signed_types; typedef typename rep_type::signed_types signed_types;
typedef typename rep_type::unsigned_types unsigned_types; typedef typename rep_type::unsigned_types unsigned_types;
typedef boost::mpl::list<float, double, long double> float_types; typedef std::tuple<float, double, long double> float_types;
typedef Exponent exponent_type; typedef Exponent exponent_type;
static const exponent_type max_exponent_limit = boost::integer_traits<exponent_type>::const_max - 2 * static_cast<exponent_type>(bit_count); static const exponent_type max_exponent_limit = boost::integer_traits<exponent_type>::const_max - 2 * static_cast<exponent_type>(bit_count);
@@ -324,7 +324,7 @@ class cpp_bin_float
return *this; return *this;
} }
typedef typename mpl::front<unsigned_types>::type ui_type; typedef typename std::tuple_element<0, unsigned_types>::type ui_type;
m_data = static_cast<ui_type>(0u); m_data = static_cast<ui_type>(0u);
m_sign = false; m_sign = false;
m_exponent = 0; m_exponent = 0;
@@ -384,7 +384,7 @@ class cpp_bin_float
return *this; return *this;
} }
typedef typename mpl::front<unsigned_types>::type ui_type; typedef typename std::tuple_element<0, unsigned_types>::type ui_type;
m_data = static_cast<ui_type>(0u); m_data = static_cast<ui_type>(0u);
m_sign = false; m_sign = false;
m_exponent = 0; m_exponent = 0;
@@ -452,7 +452,7 @@ class cpp_bin_float
return *this; return *this;
} }
typedef typename mpl::front<unsigned_types>::type ui_type; typedef typename std::tuple_element<0, unsigned_types>::type ui_type;
m_data = static_cast<ui_type>(0u); m_data = static_cast<ui_type>(0u);
m_sign = false; m_sign = false;
m_exponent = 0; m_exponent = 0;
@@ -1926,7 +1926,7 @@ using backends::digit_base_10;
using backends::digit_base_2; using backends::digit_base_2;
template <unsigned Digits, backends::digit_base_type DigitBase, class Exponent, Exponent MinE, Exponent MaxE, class Allocator> template <unsigned Digits, backends::digit_base_type DigitBase, class Exponent, Exponent MinE, Exponent MaxE, class Allocator>
struct number_category<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > : public boost::mpl::int_<boost::multiprecision::number_kind_floating_point> struct number_category<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > : public std::integral_constant<int, boost::multiprecision::number_kind_floating_point>
{}; {};
template <unsigned Digits, backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE> template <unsigned Digits, backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
@@ -1937,7 +1937,7 @@ struct expression_template_default<cpp_bin_float<Digits, DigitBase, Allocator, E
template <unsigned Digits, backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class Allocator2, class Exponent2, Exponent MinE2, Exponent MaxE2> template <unsigned Digits, backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE, class Allocator2, class Exponent2, Exponent MinE2, Exponent MaxE2>
struct is_equivalent_number_type<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, cpp_bin_float<Digits, DigitBase, Allocator2, Exponent2, MinE2, MaxE2> > struct is_equivalent_number_type<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>, cpp_bin_float<Digits, DigitBase, Allocator2, Exponent2, MinE2, MaxE2> >
: public mpl::true_ {}; : public std::integral_constant<bool, true> {};
typedef number<backends::cpp_bin_float<50> > cpp_bin_float_50; typedef number<backends::cpp_bin_float<50> > cpp_bin_float_50;
typedef number<backends::cpp_bin_float<100> > cpp_bin_float_100; typedef number<backends::cpp_bin_float<100> > cpp_bin_float_100;
@@ -1981,7 +1981,7 @@ class numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bi
if (!value.first) if (!value.first)
{ {
value.first = true; value.first = true;
typedef typename boost::mpl::front<typename number_type::backend_type::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename number_type::backend_type::unsigned_types>::type ui_type;
value.second.backend() = ui_type(1u); value.second.backend() = ui_type(1u);
value.second.backend().exponent() = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent; value.second.backend().exponent() = boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
} }
@@ -2004,7 +2004,7 @@ class numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bi
using boost::multiprecision::default_ops::eval_decrement; using boost::multiprecision::default_ops::eval_decrement;
using boost::multiprecision::default_ops::eval_left_shift; using boost::multiprecision::default_ops::eval_left_shift;
typedef typename number_type::backend_type::rep_type int_backend_type; typedef typename number_type::backend_type::rep_type int_backend_type;
typedef typename boost::mpl::front<typename int_backend_type::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename int_backend_type::unsigned_types>::type ui_type;
int_backend_type i; int_backend_type i;
i = ui_type(1u); i = ui_type(1u);
eval_left_shift(i, boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1); eval_left_shift(i, boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1);
@@ -2036,7 +2036,7 @@ class numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bi
if (!value.first) if (!value.first)
{ {
// We jump through hoops here just to keep VC12 happy (ie compiler workaround, for very strange compiler bug): // We jump through hoops here just to keep VC12 happy (ie compiler workaround, for very strange compiler bug):
typedef typename boost::mpl::front<typename number_type::backend_type::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename number_type::backend_type::unsigned_types>::type ui_type;
value.first = true; value.first = true;
value.second.backend() = ui_type(1u); value.second.backend() = ui_type(1u);
value.second = ldexp(value.second, 1 - (int)digits); value.second = ldexp(value.second, 1 - (int)digits);
@@ -2053,7 +2053,7 @@ class numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_bi
{ {
value.first = true; value.first = true;
// We jump through hoops here just to keep VC12 happy (ie compiler workaround, for very strange compiler bug): // We jump through hoops here just to keep VC12 happy (ie compiler workaround, for very strange compiler bug):
typedef typename boost::mpl::front<typename number_type::backend_type::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename number_type::backend_type::unsigned_types>::type ui_type;
value.second.backend() = ui_type(1u); value.second.backend() = ui_type(1u);
value.second = ldexp(value.second, -1); value.second = ldexp(value.second, -1);
} }
@@ -56,7 +56,7 @@ class cpp_dec_float;
} // namespace backends } // namespace backends
template <unsigned Digits10, class ExponentType, class Allocator> template <unsigned Digits10, class ExponentType, class Allocator>
struct number_category<backends::cpp_dec_float<Digits10, ExponentType, Allocator> > : public mpl::int_<number_kind_floating_point> struct number_category<backends::cpp_dec_float<Digits10, ExponentType, Allocator> > : public std::integral_constant<int, number_kind_floating_point>
{}; {};
namespace backends { namespace backends {
@@ -72,9 +72,9 @@ class cpp_dec_float
static_assert(sizeof(ExponentType) > 1, "ExponentType is too small."); static_assert(sizeof(ExponentType) > 1, "ExponentType is too small.");
public: public:
typedef mpl::list<boost::long_long_type> signed_types; typedef std::tuple<boost::long_long_type> signed_types;
typedef mpl::list<boost::ulong_long_type> unsigned_types; typedef std::tuple<boost::ulong_long_type> unsigned_types;
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
typedef ExponentType exponent_type; typedef ExponentType exponent_type;
static const std::int32_t cpp_dec_float_radix = 10L; static const std::int32_t cpp_dec_float_radix = 10L;
+74 -74
View File
@@ -103,7 +103,7 @@ struct is_trivial_cpp_int<cpp_int_base<MinBits, MaxBits, SignType, Checked, Allo
// //
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator>
struct is_unsigned_number<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> > struct is_unsigned_number<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >
: public mpl::bool_<(SignType == unsigned_magnitude) || (SignType == unsigned_packed)> : public std::integral_constant<bool, (SignType == unsigned_magnitude) || (SignType == unsigned_packed)>
{}; {};
namespace backends { namespace backends {
@@ -128,10 +128,10 @@ struct is_implicit_cpp_int_conversion<cpp_int_backend<MinBits, MaxBits, SignType
// Traits class to determine whether operations on a cpp_int may throw: // Traits class to determine whether operations on a cpp_int may throw:
// //
template <class T> template <class T>
struct is_non_throwing_cpp_int : public mpl::false_ struct is_non_throwing_cpp_int : public std::integral_constant<bool, false>
{}; {};
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType>
struct is_non_throwing_cpp_int<cpp_int_backend<MinBits, MaxBits, SignType, unchecked, void> > : public mpl::true_ struct is_non_throwing_cpp_int<cpp_int_backend<MinBits, MaxBits, SignType, unchecked, void> > : public std::integral_constant<bool, true>
{}; {};
// //
@@ -141,27 +141,27 @@ template <class T>
struct is_fixed_precision; struct is_fixed_precision;
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator>
struct is_fixed_precision<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> > struct is_fixed_precision<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >
: public mpl::bool_<max_precision<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value != UINT_MAX> : public std::integral_constant<bool, max_precision<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value != UINT_MAX>
{}; {};
namespace detail { namespace detail {
inline BOOST_MP_CXX14_CONSTEXPR void verify_new_size(unsigned new_size, unsigned min_size, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR void verify_new_size(unsigned new_size, unsigned min_size, const std::integral_constant<int, checked>&)
{ {
if (new_size < min_size) if (new_size < min_size)
BOOST_THROW_EXCEPTION(std::overflow_error("Unable to allocate sufficient storage for the value of the result: value overflows the maximum allowable magnitude.")); BOOST_THROW_EXCEPTION(std::overflow_error("Unable to allocate sufficient storage for the value of the result: value overflows the maximum allowable magnitude."));
} }
inline BOOST_MP_CXX14_CONSTEXPR void verify_new_size(unsigned /*new_size*/, unsigned /*min_size*/, const mpl::int_<unchecked>&) {} inline BOOST_MP_CXX14_CONSTEXPR void verify_new_size(unsigned /*new_size*/, unsigned /*min_size*/, const std::integral_constant<int, unchecked>&) {}
template <class U> template <class U>
inline BOOST_MP_CXX14_CONSTEXPR void verify_limb_mask(bool b, U limb, U mask, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR void verify_limb_mask(bool b, U limb, U mask, const std::integral_constant<int, checked>&)
{ {
// When we mask out "limb" with "mask", do we loose bits? If so it's an overflow error: // When we mask out "limb" with "mask", do we loose bits? If so it's an overflow error:
if (b && (limb & ~mask)) if (b && (limb & ~mask))
BOOST_THROW_EXCEPTION(std::overflow_error("Overflow in cpp_int arithmetic: there is insufficient precision in the target type to hold all of the bits of the result.")); BOOST_THROW_EXCEPTION(std::overflow_error("Overflow in cpp_int arithmetic: there is insufficient precision in the target type to hold all of the bits of the result."));
} }
template <class U> template <class U>
inline BOOST_MP_CXX14_CONSTEXPR void verify_limb_mask(bool /*b*/, U /*limb*/, U /*mask*/, const mpl::int_<unchecked>&) {} inline BOOST_MP_CXX14_CONSTEXPR void verify_limb_mask(bool /*b*/, U /*limb*/, U /*mask*/, const std::integral_constant<int, unchecked>&) {}
} // namespace detail } // namespace detail
@@ -179,7 +179,7 @@ struct cpp_int_base<MinBits, MaxBits, signed_magnitude, Checked, Allocator, fals
typedef typename detail::rebind<limb_type, Allocator>::type allocator_type; typedef typename detail::rebind<limb_type, Allocator>::type allocator_type;
typedef typename std::allocator_traits<allocator_type>::pointer limb_pointer; typedef typename std::allocator_traits<allocator_type>::pointer limb_pointer;
typedef typename std::allocator_traits<allocator_type>::const_pointer const_limb_pointer; typedef typename std::allocator_traits<allocator_type>::const_pointer const_limb_pointer;
typedef mpl::int_<Checked> checked_type; typedef std::integral_constant<int, Checked> checked_type;
// //
// Interface invariants: // Interface invariants:
@@ -528,7 +528,7 @@ struct cpp_int_base<MinBits, MinBits, signed_magnitude, Checked, void, false>
{ {
typedef limb_type* limb_pointer; typedef limb_type* limb_pointer;
typedef const limb_type* const_limb_pointer; typedef const limb_type* const_limb_pointer;
typedef mpl::int_<Checked> checked_type; typedef std::integral_constant<int, Checked> checked_type;
struct scoped_shared_storage struct scoped_shared_storage
{ {
@@ -732,7 +732,7 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, false>
{ {
typedef limb_type* limb_pointer; typedef limb_type* limb_pointer;
typedef const limb_type* const_limb_pointer; typedef const limb_type* const_limb_pointer;
typedef mpl::int_<Checked> checked_type; typedef std::integral_constant<int, Checked> checked_type;
struct scoped_shared_storage struct scoped_shared_storage
{ {
@@ -886,11 +886,11 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, false>
} }
private: private:
void check_negate(const mpl::int_<checked>&) void check_negate(const std::integral_constant<int, checked>&)
{ {
BOOST_THROW_EXCEPTION(std::range_error("Attempt to negate an unsigned number.")); BOOST_THROW_EXCEPTION(std::range_error("Attempt to negate an unsigned number."));
} }
BOOST_MP_CXX14_CONSTEXPR void check_negate(const mpl::int_<unchecked>&) {} BOOST_MP_CXX14_CONSTEXPR void check_negate(const std::integral_constant<int, unchecked>&) {}
public: public:
BOOST_MP_CXX14_CONSTEXPR void negate() BOOST_MP_NOEXCEPT_IF((Checked == unchecked)) BOOST_MP_CXX14_CONSTEXPR void negate() BOOST_MP_NOEXCEPT_IF((Checked == unchecked))
@@ -961,7 +961,7 @@ struct cpp_int_base<MinBits, MinBits, signed_magnitude, Checked, void, true>
typedef typename trivial_limb_type<MinBits>::type local_limb_type; typedef typename trivial_limb_type<MinBits>::type local_limb_type;
typedef local_limb_type* limb_pointer; typedef local_limb_type* limb_pointer;
typedef const local_limb_type* const_limb_pointer; typedef const local_limb_type* const_limb_pointer;
typedef mpl::int_<Checked> checked_type; typedef std::integral_constant<int, Checked> checked_type;
struct scoped_shared_storage struct scoped_shared_storage
{ {
@@ -985,7 +985,7 @@ struct cpp_int_base<MinBits, MinBits, signed_magnitude, Checked, void, true>
protected: protected:
template <class T> template <class T>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!(!boost::multiprecision::detail::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits)))>::type BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!(!boost::multiprecision::detail::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits)))>::type
check_in_range(T val, const mpl::int_<checked>&) check_in_range(T val, const std::integral_constant<int, checked>&)
{ {
typedef typename std::common_type<typename boost::multiprecision::detail::make_unsigned<T>::type, local_limb_type>::type common_type; typedef typename std::common_type<typename boost::multiprecision::detail::make_unsigned<T>::type, local_limb_type>::type common_type;
@@ -994,7 +994,7 @@ struct cpp_int_base<MinBits, MinBits, signed_magnitude, Checked, void, true>
} }
template <class T> template <class T>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!(boost::multiprecision::detail::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits)))>::type BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!(boost::multiprecision::detail::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits)))>::type
check_in_range(T val, const mpl::int_<checked>&) check_in_range(T val, const std::integral_constant<int, checked>&)
{ {
using std::abs; using std::abs;
typedef typename std::common_type<T, local_limb_type>::type common_type; typedef typename std::common_type<T, local_limb_type>::type common_type;
@@ -1003,7 +1003,7 @@ struct cpp_int_base<MinBits, MinBits, signed_magnitude, Checked, void, true>
BOOST_THROW_EXCEPTION(std::range_error("The argument to a cpp_int constructor exceeded the largest value it can represent.")); BOOST_THROW_EXCEPTION(std::range_error("The argument to a cpp_int constructor exceeded the largest value it can represent."));
} }
template <class T, int C> template <class T, int C>
BOOST_MP_CXX14_CONSTEXPR void check_in_range(T, const mpl::int_<C>&) BOOST_NOEXCEPT {} BOOST_MP_CXX14_CONSTEXPR void check_in_range(T, const std::integral_constant<int, C>&) BOOST_NOEXCEPT {}
template <class T> template <class T>
BOOST_MP_CXX14_CONSTEXPR void check_in_range(T val) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<T>(), checked_type()))) BOOST_MP_CXX14_CONSTEXPR void check_in_range(T val) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<T>(), checked_type())))
@@ -1140,7 +1140,7 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, true>
local_limb_type m_data; local_limb_type m_data;
typedef mpl::int_<Checked> checked_type; typedef std::integral_constant<int, Checked> checked_type;
// //
// Interface invariants: // Interface invariants:
@@ -1150,7 +1150,7 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, true>
protected: protected:
template <class T> template <class T>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if< !(std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits))>::type BOOST_MP_CXX14_CONSTEXPR typename std::enable_if< !(std::numeric_limits<T>::is_specialized && (std::numeric_limits<T>::digits <= (int)MinBits))>::type
check_in_range(T val, const mpl::int_<checked>&, const std::integral_constant<bool, false>&) check_in_range(T val, const std::integral_constant<int, checked>&, const std::integral_constant<bool, false>&)
{ {
typedef typename std::common_type<T, local_limb_type>::type common_type; typedef typename std::common_type<T, local_limb_type>::type common_type;
@@ -1158,7 +1158,7 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, true>
BOOST_THROW_EXCEPTION(std::range_error("The argument to a cpp_int constructor exceeded the largest value it can represent.")); BOOST_THROW_EXCEPTION(std::range_error("The argument to a cpp_int constructor exceeded the largest value it can represent."));
} }
template <class T> template <class T>
BOOST_MP_CXX14_CONSTEXPR void check_in_range(T val, const mpl::int_<checked>&, const std::integral_constant<bool, true>&) BOOST_MP_CXX14_CONSTEXPR void check_in_range(T val, const std::integral_constant<int, checked>&, const std::integral_constant<bool, true>&)
{ {
typedef typename std::common_type<T, local_limb_type>::type common_type; typedef typename std::common_type<T, local_limb_type>::type common_type;
@@ -1168,7 +1168,7 @@ struct cpp_int_base<MinBits, MinBits, unsigned_magnitude, Checked, void, true>
BOOST_THROW_EXCEPTION(std::range_error("The argument to an unsigned cpp_int constructor was negative.")); BOOST_THROW_EXCEPTION(std::range_error("The argument to an unsigned cpp_int constructor was negative."));
} }
template <class T, int C, bool B> template <class T, int C, bool B>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void check_in_range(T, const mpl::int_<C>&, const std::integral_constant<bool, B>&) BOOST_NOEXCEPT {} BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void check_in_range(T, const std::integral_constant<int, C>&, const std::integral_constant<bool, B>&) BOOST_NOEXCEPT {}
template <class T> template <class T>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void check_in_range(T val) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<T>(), checked_type(), boost::multiprecision::detail::is_signed<T>()))) BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void check_in_range(T val) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_base>().check_in_range(std::declval<T>(), checked_type(), boost::multiprecision::detail::is_signed<T>())))
@@ -1292,8 +1292,8 @@ struct is_allowed_cpp_int_base_conversion : public std::conditional<
|| std::is_same<Arg, double_limb_type>::value || std::is_same<Arg, signed_double_limb_type>::value || std::is_same<Arg, double_limb_type>::value || std::is_same<Arg, signed_double_limb_type>::value
#endif #endif
|| literals::detail::is_value_pack<Arg>::value || (is_trivial_cpp_int<Base>::value && boost::multiprecision::detail::is_arithmetic<Arg>::value), || literals::detail::is_value_pack<Arg>::value || (is_trivial_cpp_int<Base>::value && boost::multiprecision::detail::is_arithmetic<Arg>::value),
mpl::true_, std::integral_constant<bool, true>,
mpl::false_>::type std::integral_constant<bool, false>>::type
{}; {};
// //
// Now the actual backend, normalising parameters passed to the base class: // Now the actual backend, normalising parameters passed to the base class:
@@ -1317,25 +1317,25 @@ struct cpp_int_backend
Allocator, Allocator,
is_trivial_cpp_int<self_type>::value> is_trivial_cpp_int<self_type>::value>
base_type; base_type;
typedef mpl::bool_<is_trivial_cpp_int<self_type>::value> trivial_tag; typedef std::integral_constant<bool, is_trivial_cpp_int<self_type>::value> trivial_tag;
public: public:
typedef typename mpl::if_< typedef typename std::conditional<
trivial_tag, is_trivial_cpp_int<self_type>::value,
mpl::list< std::tuple<
signed char, short, int, long, signed char, short, int, long,
boost::long_long_type, signed_double_limb_type>, boost::long_long_type, signed_double_limb_type>,
mpl::list<signed_limb_type, signed_double_limb_type> >::type signed_types; std::tuple<signed_limb_type, signed_double_limb_type> >::type signed_types;
typedef typename mpl::if_< typedef typename std::conditional<
trivial_tag, is_trivial_cpp_int<self_type>::value,
mpl::list<unsigned char, unsigned short, unsigned, std::tuple<unsigned char, unsigned short, unsigned,
unsigned long, boost::ulong_long_type, double_limb_type>, unsigned long, boost::ulong_long_type, double_limb_type>,
mpl::list<limb_type, double_limb_type> >::type unsigned_types; std::tuple<limb_type, double_limb_type> >::type unsigned_types;
typedef typename mpl::if_< typedef typename std::conditional<
trivial_tag, is_trivial_cpp_int<self_type>::value,
mpl::list<float, double, long double>, std::tuple<float, double, long double>,
mpl::list<long double> >::type float_types; std::tuple<long double> >::type float_types;
typedef mpl::int_<Checked> checked_type; typedef std::integral_constant<int, Checked> checked_type;
BOOST_MP_FORCEINLINE constexpr cpp_int_backend() BOOST_NOEXCEPT {} BOOST_MP_FORCEINLINE constexpr cpp_int_backend() BOOST_NOEXCEPT {}
BOOST_MP_FORCEINLINE constexpr cpp_int_backend(const cpp_int_backend& o) BOOST_MP_NOEXCEPT_IF(std::is_void<Allocator>::value) : base_type(o) {} BOOST_MP_FORCEINLINE constexpr cpp_int_backend(const cpp_int_backend& o) BOOST_MP_NOEXCEPT_IF(std::is_void<Allocator>::value) : base_type(o) {}
@@ -1367,7 +1367,7 @@ struct cpp_int_backend
private: private:
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, mpl::true_ const&, mpl::true_ const&) BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, std::integral_constant<bool, true> const&, std::integral_constant<bool, true> const&)
{ {
// Assigning trivial type to trivial type: // Assigning trivial type to trivial type:
this->check_in_range(*other.limbs()); this->check_in_range(*other.limbs());
@@ -1376,7 +1376,7 @@ struct cpp_int_backend
this->normalize(); this->normalize();
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, mpl::true_ const&, mpl::false_ const&) BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, std::integral_constant<bool, true> const&, std::integral_constant<bool, false> const&)
{ {
// non-trivial to trivial narrowing conversion: // non-trivial to trivial narrowing conversion:
double_limb_type v = *other.limbs(); double_limb_type v = *other.limbs();
@@ -1393,7 +1393,7 @@ struct cpp_int_backend
this->normalize(); this->normalize();
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, mpl::false_ const&, mpl::true_ const&) BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, std::integral_constant<bool, false> const&, std::integral_constant<bool, true> const&)
{ {
// trivial to non-trivial, treat the trivial argument as if it were an unsigned arithmetic type, then set the sign afterwards: // trivial to non-trivial, treat the trivial argument as if it were an unsigned arithmetic type, then set the sign afterwards:
*this = static_cast< *this = static_cast<
@@ -1403,7 +1403,7 @@ struct cpp_int_backend
this->sign(other.sign()); this->sign(other.sign());
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, mpl::false_ const&, mpl::false_ const&) BOOST_MP_CXX14_CONSTEXPR void do_assign(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& other, std::integral_constant<bool, false> const&, std::integral_constant<bool, false> const&)
{ {
// regular non-trivial to non-trivial assign: // regular non-trivial to non-trivial assign:
this->resize(other.size(), other.size()); this->resize(other.size(), other.size());
@@ -1437,8 +1437,8 @@ struct cpp_int_backend
{ {
do_assign( do_assign(
other, other,
mpl::bool_<is_trivial_cpp_int<self_type>::value>(), std::integral_constant<bool, is_trivial_cpp_int<self_type>::value>(),
mpl::bool_<is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value>()); std::integral_constant<bool, is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value>());
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
explicit BOOST_MP_CXX14_CONSTEXPR cpp_int_backend( explicit BOOST_MP_CXX14_CONSTEXPR cpp_int_backend(
@@ -1448,8 +1448,8 @@ struct cpp_int_backend
{ {
do_assign( do_assign(
other, other,
mpl::bool_<is_trivial_cpp_int<self_type>::value>(), std::integral_constant<bool, is_trivial_cpp_int<self_type>::value>(),
mpl::bool_<is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value>()); std::integral_constant<bool, is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value>());
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR cpp_int_backend& operator=( BOOST_MP_CXX14_CONSTEXPR cpp_int_backend& operator=(
@@ -1457,8 +1457,8 @@ struct cpp_int_backend
{ {
do_assign( do_assign(
other, other,
mpl::bool_<is_trivial_cpp_int<self_type>::value>(), std::integral_constant<bool, is_trivial_cpp_int<self_type>::value>(),
mpl::bool_<is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value>()); std::integral_constant<bool, is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value>());
return *this; return *this;
} }
constexpr cpp_int_backend(const cpp_int_backend& a, const literals::detail::negate_tag& tag) constexpr cpp_int_backend(const cpp_int_backend& a, const literals::detail::negate_tag& tag)
@@ -1484,7 +1484,7 @@ struct cpp_int_backend
} }
private: private:
template <class A> template <class A>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_unsigned<A>::value>::type do_assign_arithmetic(A val, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_unsigned<A>::value>::type do_assign_arithmetic(A val, const std::integral_constant<bool, true>&)
BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().check_in_range(std::declval<A>()))) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().check_in_range(std::declval<A>())))
{ {
this->check_in_range(val); this->check_in_range(val);
@@ -1493,7 +1493,7 @@ struct cpp_int_backend
this->normalize(); this->normalize();
} }
template <class A> template <class A>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!(boost::multiprecision::detail::is_unsigned<A>::value || !boost::multiprecision::detail::is_integral<A>::value)>::type do_assign_arithmetic(A val, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!(boost::multiprecision::detail::is_unsigned<A>::value || !boost::multiprecision::detail::is_integral<A>::value)>::type do_assign_arithmetic(A val, const std::integral_constant<bool, true>&)
BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().check_in_range(std::declval<A>())) && noexcept(std::declval<cpp_int_backend>().sign(true))) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().check_in_range(std::declval<A>())) && noexcept(std::declval<cpp_int_backend>().sign(true)))
{ {
this->check_in_range(val); this->check_in_range(val);
@@ -1502,26 +1502,26 @@ struct cpp_int_backend
this->normalize(); this->normalize();
} }
template <class A> template <class A>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!boost::multiprecision::detail::is_integral<A>::value>::type do_assign_arithmetic(A val, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!boost::multiprecision::detail::is_integral<A>::value>::type do_assign_arithmetic(A val, const std::integral_constant<bool, true>&)
{ {
this->check_in_range(val); this->check_in_range(val);
*this->limbs() = (val < 0) ? static_cast<typename self_type::local_limb_type>(boost::multiprecision::detail::abs(val)) : static_cast<typename self_type::local_limb_type>(val); *this->limbs() = (val < 0) ? static_cast<typename self_type::local_limb_type>(boost::multiprecision::detail::abs(val)) : static_cast<typename self_type::local_limb_type>(val);
this->sign(val < 0); this->sign(val < 0);
this->normalize(); this->normalize();
} }
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(limb_type i, const mpl::false_&) BOOST_NOEXCEPT BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(limb_type i, const std::integral_constant<bool, false>&) BOOST_NOEXCEPT
{ {
this->resize(1, 1); this->resize(1, 1);
*this->limbs() = i; *this->limbs() = i;
this->sign(false); this->sign(false);
} }
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(signed_limb_type i, const mpl::false_&) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().sign(true))) BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(signed_limb_type i, const std::integral_constant<bool, false>&) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().sign(true)))
{ {
this->resize(1, 1); this->resize(1, 1);
*this->limbs() = static_cast<limb_type>(boost::multiprecision::detail::unsigned_abs(i)); *this->limbs() = static_cast<limb_type>(boost::multiprecision::detail::unsigned_abs(i));
this->sign(i < 0); this->sign(i < 0);
} }
BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(double_limb_type i, const mpl::false_&) BOOST_NOEXCEPT BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(double_limb_type i, const std::integral_constant<bool, false>&) BOOST_NOEXCEPT
{ {
static_assert(sizeof(i) == 2 * sizeof(limb_type), "Failed integer size check"); static_assert(sizeof(i) == 2 * sizeof(limb_type), "Failed integer size check");
static_assert(base_type::internal_limb_count >= 2, "Failed internal limb count"); static_assert(base_type::internal_limb_count >= 2, "Failed internal limb count");
@@ -1535,7 +1535,7 @@ struct cpp_int_backend
this->resize(p[1] ? 2 : 1, p[1] ? 2 : 1); this->resize(p[1] ? 2 : 1, p[1] ? 2 : 1);
this->sign(false); this->sign(false);
} }
BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(signed_double_limb_type i, const mpl::false_&) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().sign(true))) BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(signed_double_limb_type i, const std::integral_constant<bool, false>&) BOOST_MP_NOEXCEPT_IF(noexcept(std::declval<cpp_int_backend>().sign(true)))
{ {
static_assert(sizeof(i) == 2 * sizeof(limb_type), "double limb type size check failed"); static_assert(sizeof(i) == 2 * sizeof(limb_type), "double limb type size check failed");
static_assert(base_type::internal_limb_count >= 2, "Failed internal limb count check"); static_assert(base_type::internal_limb_count >= 2, "Failed internal limb count check");
@@ -1554,7 +1554,7 @@ struct cpp_int_backend
this->sign(s); this->sign(s);
} }
BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(long double a, const mpl::false_&) BOOST_MP_CXX14_CONSTEXPR void do_assign_arithmetic(long double a, const std::integral_constant<bool, false>&)
{ {
using default_ops::eval_add; using default_ops::eval_add;
using default_ops::eval_subtract; using default_ops::eval_subtract;
@@ -1564,7 +1564,7 @@ struct cpp_int_backend
if (a < 0) if (a < 0)
{ {
do_assign_arithmetic(-a, mpl::false_()); do_assign_arithmetic(-a, std::integral_constant<bool, false>());
this->sign(true); this->sign(true);
return; return;
} }
@@ -1620,7 +1620,7 @@ struct cpp_int_backend
} }
private: private:
void do_assign_string(const char* s, const mpl::true_&) void do_assign_string(const char* s, const std::integral_constant<bool, true>&)
{ {
std::size_t n = s ? std::strlen(s) : 0; std::size_t n = s ? std::strlen(s) : 0;
*this = 0; *this = 0;
@@ -1671,7 +1671,7 @@ struct cpp_int_backend
if (isneg) if (isneg)
this->negate(); this->negate();
} }
void do_assign_string(const char* s, const mpl::false_&) void do_assign_string(const char* s, const std::integral_constant<bool, false>&)
{ {
using default_ops::eval_add; using default_ops::eval_add;
using default_ops::eval_multiply; using default_ops::eval_multiply;
@@ -1838,7 +1838,7 @@ struct cpp_int_backend
} }
private: private:
std::string do_get_trivial_string(std::ios_base::fmtflags f, const mpl::false_&) const std::string do_get_trivial_string(std::ios_base::fmtflags f, const std::integral_constant<bool, false>&) const
{ {
typedef typename std::conditional<sizeof(typename base_type::local_limb_type) == 1, unsigned, typename base_type::local_limb_type>::type io_type; typedef typename std::conditional<sizeof(typename base_type::local_limb_type) == 1, unsigned, typename base_type::local_limb_type>::type io_type;
if (this->sign() && (((f & std::ios_base::hex) == std::ios_base::hex) || ((f & std::ios_base::oct) == std::ios_base::oct))) if (this->sign() && (((f & std::ios_base::hex) == std::ios_base::hex) || ((f & std::ios_base::oct) == std::ios_base::oct)))
@@ -1854,7 +1854,7 @@ struct cpp_int_backend
result += ss.str(); result += ss.str();
return result; return result;
} }
std::string do_get_trivial_string(std::ios_base::fmtflags f, const mpl::true_&) const std::string do_get_trivial_string(std::ios_base::fmtflags f, const std::integral_constant<bool, true>&) const
{ {
// Even though we have only one limb, we can't do IO on it :-( // Even though we have only one limb, we can't do IO on it :-(
int base = 10; int base = 10;
@@ -1932,15 +1932,15 @@ struct cpp_int_backend
} }
return result; return result;
} }
std::string do_get_string(std::ios_base::fmtflags f, const mpl::true_&) const std::string do_get_string(std::ios_base::fmtflags f, const std::integral_constant<bool, true>&) const
{ {
#ifdef BOOST_MP_NO_DOUBLE_LIMB_TYPE_IO #ifdef BOOST_MP_NO_DOUBLE_LIMB_TYPE_IO
return do_get_trivial_string(f, mpl::bool_<std::is_same<typename base_type::local_limb_type, double_limb_type>::value>()); return do_get_trivial_string(f, std::integral_constant<bool, std::is_same<typename base_type::local_limb_type, double_limb_type>::value>());
#else #else
return do_get_trivial_string(f, mpl::bool_<false>()); return do_get_trivial_string(f, std::integral_constant<bool, false>());
#endif #endif
} }
std::string do_get_string(std::ios_base::fmtflags f, const mpl::false_&) const std::string do_get_string(std::ios_base::fmtflags f, const std::integral_constant<bool, false>&) const
{ {
using default_ops::eval_get_sign; using default_ops::eval_get_sign;
int base = 10; int base = 10;
@@ -2047,7 +2047,7 @@ struct cpp_int_backend
private: private:
template <class Container> template <class Container>
void construct_from_container(const Container& c, const mpl::false_&) void construct_from_container(const Container& c, const std::integral_constant<bool, false>&)
{ {
// //
// We assume that c is a sequence of (unsigned) bytes with the most significant byte first: // We assume that c is a sequence of (unsigned) bytes with the most significant byte first:
@@ -2075,7 +2075,7 @@ struct cpp_int_backend
} }
} }
template <class Container> template <class Container>
BOOST_MP_CXX14_CONSTEXPR void construct_from_container(const Container& c, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR void construct_from_container(const Container& c, const std::integral_constant<bool, true>&)
{ {
// //
// We assume that c is a sequence of (unsigned) bytes with the most significant byte first: // We assume that c is a sequence of (unsigned) bytes with the most significant byte first:
@@ -2108,7 +2108,7 @@ struct cpp_int_backend
construct_from_container(c, trivial_tag()); construct_from_container(c, trivial_tag());
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const mpl::false_&, const mpl::false_&) const BOOST_NOEXCEPT BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&) const BOOST_NOEXCEPT
{ {
if (this->sign() != o.sign()) if (this->sign() != o.sign())
return this->sign() ? -1 : 1; return this->sign() ? -1 : 1;
@@ -2121,19 +2121,19 @@ struct cpp_int_backend
return result; return result;
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const mpl::true_&, const mpl::false_&) const BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&) const
{ {
cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> t(*this); cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> t(*this);
return t.compare(o); return t.compare(o);
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const mpl::false_&, const mpl::true_&) const BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&) const
{ {
cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> t(o); cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> t(o);
return compare(t); return compare(t);
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const mpl::true_&, const mpl::true_&) const BOOST_NOEXCEPT BOOST_MP_CXX14_CONSTEXPR int compare_imp(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&) const BOOST_NOEXCEPT
{ {
if (this->sign()) if (this->sign())
{ {
@@ -2154,8 +2154,8 @@ struct cpp_int_backend
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR int compare(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) const BOOST_NOEXCEPT BOOST_MP_CXX14_CONSTEXPR int compare(const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) const BOOST_NOEXCEPT
{ {
typedef mpl::bool_<is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value> t1; typedef std::integral_constant<bool, is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value> t1;
typedef mpl::bool_<is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value> t2; typedef std::integral_constant<bool, is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value> t2;
return compare_imp(o, t1(), t2()); return compare_imp(o, t1(), t2());
} }
template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
@@ -2210,7 +2210,7 @@ struct double_precision_type<backends::cpp_int_backend<MinBits, MaxBits, SignTyp
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
struct is_equivalent_number_type<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, backends::cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > struct is_equivalent_number_type<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, backends::cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >
: public mpl::bool_<std::numeric_limits<number<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, et_on> >::digits == std::numeric_limits<number<backends::cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>, et_on> >::digits>{}; : public std::integral_constant<bool, std::numeric_limits<number<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, et_on> >::digits == std::numeric_limits<number<backends::cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>, et_on> >::digits>{};
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked>
struct expression_template_default<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, void> > struct expression_template_default<backends::cpp_int_backend<MinBits, MaxBits, SignType, Checked, void> >
@@ -2221,7 +2221,7 @@ struct expression_template_default<backends::cpp_int_backend<MinBits, MaxBits, S
using boost::multiprecision::backends::cpp_int_backend; using boost::multiprecision::backends::cpp_int_backend;
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator>
struct number_category<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> > : public mpl::int_<number_kind_integer> struct number_category<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> > : public std::integral_constant<int, number_kind_integer>
{}; {};
typedef number<cpp_int_backend<> > cpp_int; typedef number<cpp_int_backend<> > cpp_int;
@@ -18,7 +18,7 @@ namespace boost { namespace multiprecision { namespace backends {
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op( BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result, cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& result,
const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const mpl::int_<checked>&) const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o, const std::integral_constant<int, checked>&)
{ {
if (result.sign() || o.sign()) if (result.sign() || o.sign())
BOOST_THROW_EXCEPTION(std::range_error("Bitwise operations on negative values results in undefined behavior.")); BOOST_THROW_EXCEPTION(std::range_error("Bitwise operations on negative values results in undefined behavior."));
@@ -27,11 +27,11 @@ BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op( BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&, cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&,
const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>&, const mpl::int_<unchecked>&) {} const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>&, const std::integral_constant<int, unchecked>&) {}
template <unsigned MinBits1, unsigned MaxBits1, cpp_int_check_type Checked1, class Allocator1> template <unsigned MinBits1, unsigned MaxBits1, cpp_int_check_type Checked1, class Allocator1>
BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op( BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
const cpp_int_backend<MinBits1, MaxBits1, signed_magnitude, Checked1, Allocator1>& result, const mpl::int_<checked>&) const cpp_int_backend<MinBits1, MaxBits1, signed_magnitude, Checked1, Allocator1>& result, const std::integral_constant<int, checked>&)
{ {
if (result.sign()) if (result.sign())
BOOST_THROW_EXCEPTION(std::range_error("Bitwise operations on negative values results in undefined behavior.")); BOOST_THROW_EXCEPTION(std::range_error("Bitwise operations on negative values results in undefined behavior."));
@@ -39,17 +39,17 @@ BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
template <unsigned MinBits1, unsigned MaxBits1, cpp_int_check_type Checked1, class Allocator1> template <unsigned MinBits1, unsigned MaxBits1, cpp_int_check_type Checked1, class Allocator1>
BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op( BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
const cpp_int_backend<MinBits1, MaxBits1, unsigned_magnitude, Checked1, Allocator1>&, const mpl::int_<checked>&) {} const cpp_int_backend<MinBits1, MaxBits1, unsigned_magnitude, Checked1, Allocator1>&, const std::integral_constant<int, checked>&) {}
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1> template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op( BOOST_MP_CXX14_CONSTEXPR void is_valid_bitwise_op(
cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&, const mpl::int_<unchecked>&) {} cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&, const std::integral_constant<int, unchecked>&) {}
template <class CppInt1, class CppInt2, class Op> template <class CppInt1, class CppInt2, class Op>
BOOST_MP_CXX14_CONSTEXPR void bitwise_op( BOOST_MP_CXX14_CONSTEXPR void bitwise_op(
CppInt1& result, CppInt1& result,
const CppInt2& o, const CppInt2& o,
Op op, const mpl::true_&) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<CppInt1>::value)) Op op, const std::integral_constant<bool, true>&) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<CppInt1>::value))
{ {
// //
// There are 4 cases: // There are 4 cases:
@@ -189,7 +189,7 @@ template <class CppInt1, class CppInt2, class Op>
BOOST_MP_CXX14_CONSTEXPR void bitwise_op( BOOST_MP_CXX14_CONSTEXPR void bitwise_op(
CppInt1& result, CppInt1& result,
const CppInt2& o, const CppInt2& o,
Op op, const mpl::false_&) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<CppInt1>::value)) Op op, const std::integral_constant<bool, false>&) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<CppInt1>::value))
{ {
// //
// Both arguments are unsigned types, very simple case handled as a special case. // Both arguments are unsigned types, very simple case handled as a special case.
@@ -234,7 +234,7 @@ eval_bitwise_and(
const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)) const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value))
{ {
bitwise_op(result, o, bit_and(), bitwise_op(result, o, bit_and(),
mpl::bool_ < std::numeric_limits<number<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> > >::is_signed || std::numeric_limits<number<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > >::is_signed > ()); std::integral_constant<bool, std::numeric_limits<number<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> > >::is_signed || std::numeric_limits<number<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > >::is_signed > ());
} }
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
@@ -244,7 +244,7 @@ eval_bitwise_or(
const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)) const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value))
{ {
bitwise_op(result, o, bit_or(), bitwise_op(result, o, bit_or(),
mpl::bool_ < std::numeric_limits<number<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> > >::is_signed || std::numeric_limits<number<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > >::is_signed > ()); std::integral_constant<bool, std::numeric_limits<number<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> > >::is_signed || std::numeric_limits<number<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > >::is_signed > ());
} }
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2> template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
@@ -254,7 +254,7 @@ eval_bitwise_xor(
const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)) const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& o) BOOST_MP_NOEXCEPT_IF((is_non_throwing_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value))
{ {
bitwise_op(result, o, bit_xor(), bitwise_op(result, o, bit_xor(),
mpl::bool_ < std::numeric_limits<number<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> > >::is_signed || std::numeric_limits<number<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > >::is_signed > ()); std::integral_constant<bool, std::numeric_limits<number<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> > >::is_signed || std::numeric_limits<number<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> > >::is_signed > ());
} }
// //
// Again for operands which are single limbs: // Again for operands which are single limbs:
@@ -35,7 +35,7 @@ inline void raise_div_overflow()
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_add_imp(A a, A b, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR A checked_add_imp(A a, A b, const std::integral_constant<bool, true>&)
{ {
if (a > 0) if (a > 0)
{ {
@@ -50,25 +50,25 @@ inline BOOST_MP_CXX14_CONSTEXPR A checked_add_imp(A a, A b, const mpl::true_&)
return a + b; return a + b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_add_imp(A a, A b, const mpl::false_&) inline BOOST_MP_CXX14_CONSTEXPR A checked_add_imp(A a, A b, const std::integral_constant<bool, false>&)
{ {
if ((integer_traits<A>::const_max - b) < a) if ((integer_traits<A>::const_max - b) < a)
raise_add_overflow(); raise_add_overflow();
return a + b; return a + b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_add(A a, A b, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_add(A a, A b, const std::integral_constant<int, checked>&)
{ {
return checked_add_imp(a, b, mpl::bool_<boost::multiprecision::detail::is_signed<A>::value && boost::multiprecision::detail::is_integral<A>::value > ()); return checked_add_imp(a, b, std::integral_constant<bool, boost::multiprecision::detail::is_signed<A>::value && boost::multiprecision::detail::is_integral<A>::value > ());
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_add(A a, A b, const mpl::int_<unchecked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_add(A a, A b, const std::integral_constant<int, unchecked>&)
{ {
return a + b; return a + b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract_imp(A a, A b, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract_imp(A a, A b, const std::integral_constant<bool, true>&)
{ {
if (a > 0) if (a > 0)
{ {
@@ -83,25 +83,25 @@ inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract_imp(A a, A b, const mpl::true
return a - b; return a - b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract_imp(A a, A b, const mpl::false_&) inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract_imp(A a, A b, const std::integral_constant<bool, false>&)
{ {
if (a < b) if (a < b)
raise_subtract_overflow(); raise_subtract_overflow();
return a - b; return a - b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract(A a, A b, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract(A a, A b, const std::integral_constant<int, checked>&)
{ {
return checked_subtract_imp(a, b, mpl::bool_<boost::multiprecision::detail::is_signed<A>::value && boost::multiprecision::detail::is_integral<A>::value>()); return checked_subtract_imp(a, b, std::integral_constant<bool, boost::multiprecision::detail::is_signed<A>::value && boost::multiprecision::detail::is_integral<A>::value>());
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract(A a, A b, const mpl::int_<unchecked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_subtract(A a, A b, const std::integral_constant<int, unchecked>&)
{ {
return a - b; return a - b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_multiply(A a, A b, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_multiply(A a, A b, const std::integral_constant<int, checked>&)
{ {
BOOST_MP_USING_ABS BOOST_MP_USING_ABS
if (a && (integer_traits<A>::const_max / abs(a) < abs(b))) if (a && (integer_traits<A>::const_max / abs(a) < abs(b)))
@@ -109,26 +109,26 @@ inline BOOST_MP_CXX14_CONSTEXPR A checked_multiply(A a, A b, const mpl::int_<che
return a * b; return a * b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_multiply(A a, A b, const mpl::int_<unchecked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_multiply(A a, A b, const std::integral_constant<int, unchecked>&)
{ {
return a * b; return a * b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_divide(A a, A b, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_divide(A a, A b, const std::integral_constant<int, checked>&)
{ {
if (b == 0) if (b == 0)
raise_div_overflow(); raise_div_overflow();
return a / b; return a / b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_divide(A a, A b, const mpl::int_<unchecked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_divide(A a, A b, const std::integral_constant<int, unchecked>&)
{ {
return a / b; return a / b;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_left_shift(A a, boost::ulong_long_type shift, const mpl::int_<checked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_left_shift(A a, boost::ulong_long_type shift, const std::integral_constant<int, checked>&)
{ {
if (a && shift) if (a && shift)
{ {
@@ -138,7 +138,7 @@ inline BOOST_MP_CXX14_CONSTEXPR A checked_left_shift(A a, boost::ulong_long_type
return a << shift; return a << shift;
} }
template <class A> template <class A>
inline BOOST_MP_CXX14_CONSTEXPR A checked_left_shift(A a, boost::ulong_long_type shift, const mpl::int_<unchecked>&) inline BOOST_MP_CXX14_CONSTEXPR A checked_left_shift(A a, boost::ulong_long_type shift, const std::integral_constant<int, unchecked>&)
{ {
return (shift >= sizeof(A) * CHAR_BIT) ? 0 : a << shift; return (shift >= sizeof(A) * CHAR_BIT) ? 0 : a << shift;
} }
@@ -8,8 +8,6 @@
#include <boost/integer.hpp> #include <boost/integer.hpp>
#include <boost/integer_traits.hpp> #include <boost/integer_traits.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
namespace boost { namespace boost {
@@ -12,7 +12,7 @@ namespace multiprecision {
namespace detail { namespace detail {
template <class Backend, class Unsigned> template <class Backend, class Unsigned>
void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const mpl::false_& tag) void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const std::integral_constant<bool, false>& tag)
{ {
unsigned limb = bit_location / (sizeof(limb_type) * CHAR_BIT); unsigned limb = bit_location / (sizeof(limb_type) * CHAR_BIT);
unsigned shift = bit_location % (sizeof(limb_type) * CHAR_BIT); unsigned shift = bit_location % (sizeof(limb_type) * CHAR_BIT);
@@ -42,7 +42,7 @@ void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned ch
} }
} }
template <class Backend, class Unsigned> template <class Backend, class Unsigned>
void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const mpl::true_&) void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned chunk_bits, const std::integral_constant<bool, true>&)
{ {
typedef typename Backend::local_limb_type local_limb_type; typedef typename Backend::local_limb_type local_limb_type;
// //
@@ -66,7 +66,7 @@ void assign_bits(Backend& val, Unsigned bits, unsigned bit_location, unsigned ch
} }
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator>
inline void resize_to_bit_size(cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& newval, unsigned bits, const mpl::false_&) inline void resize_to_bit_size(cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& newval, unsigned bits, const std::integral_constant<bool, false>&)
{ {
unsigned limb_count = static_cast<unsigned>(bits / (sizeof(limb_type) * CHAR_BIT)); unsigned limb_count = static_cast<unsigned>(bits / (sizeof(limb_type) * CHAR_BIT));
if (bits % (sizeof(limb_type) * CHAR_BIT)) if (bits % (sizeof(limb_type) * CHAR_BIT))
@@ -78,7 +78,7 @@ inline void resize_to_bit_size(cpp_int_backend<MinBits, MaxBits, SignType, Check
std::memset(newval.limbs(), 0, newval.size() * sizeof(limb_type)); std::memset(newval.limbs(), 0, newval.size() * sizeof(limb_type));
} }
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator> template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator>
inline void resize_to_bit_size(cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& newval, unsigned, const mpl::true_&) inline void resize_to_bit_size(cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& newval, unsigned, const std::integral_constant<bool, true>&)
{ {
*newval.limbs() = 0; *newval.limbs() = 0;
} }
@@ -177,7 +177,7 @@ import_bits(
namespace detail { namespace detail {
template <class Backend> template <class Backend>
std::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const mpl::false_& tag) std::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const std::integral_constant<bool, false>& tag)
{ {
unsigned limb = location / (sizeof(limb_type) * CHAR_BIT); unsigned limb = location / (sizeof(limb_type) * CHAR_BIT);
unsigned shift = location % (sizeof(limb_type) * CHAR_BIT); unsigned shift = location % (sizeof(limb_type) * CHAR_BIT);
@@ -194,7 +194,7 @@ std::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned coun
} }
template <class Backend> template <class Backend>
inline std::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const mpl::true_&) inline std::uintmax_t extract_bits(const Backend& val, unsigned location, unsigned count, const std::integral_constant<bool, true>&)
{ {
typename Backend::local_limb_type result = *val.limbs(); typename Backend::local_limb_type result = *val.limbs();
typename Backend::local_limb_type mask = count >= std::numeric_limits<typename Backend::local_limb_type>::digits ? ~static_cast<typename Backend::local_limb_type>(0) : (static_cast<typename Backend::local_limb_type>(1u) << count) - 1; typename Backend::local_limb_type mask = count >= std::numeric_limits<typename Backend::local_limb_type>::digits ? ~static_cast<typename Backend::local_limb_type>(0) : (static_cast<typename Backend::local_limb_type>(1u) << count) - 1;
+14 -14
View File
@@ -21,7 +21,7 @@ namespace detail {
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_min(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::true_&) get_min(const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&)
{ {
// Bounded, signed, and no allocator. // Bounded, signed, and no allocator.
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type;
@@ -37,7 +37,7 @@ get_min(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::tr
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_min(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::false_&) get_min(const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&)
{ {
// Bounded, signed, and an allocator (can't be constexpr). // Bounded, signed, and an allocator (can't be constexpr).
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type;
@@ -48,7 +48,7 @@ get_min(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::fa
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_min(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::true_&) get_min(const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&)
{ {
// Bounded, unsigned, no allocator (can be constexpr): // Bounded, unsigned, no allocator (can be constexpr):
#ifdef BOOST_MP_NO_CONSTEXPR_DETECTION #ifdef BOOST_MP_NO_CONSTEXPR_DETECTION
@@ -62,7 +62,7 @@ get_min(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::t
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_min(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::false_&) get_min(const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&)
{ {
// Bounded and unsigned with allocator (no constexpr): // Bounded and unsigned with allocator (no constexpr):
static const boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> val(0u); static const boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> val(0u);
@@ -71,7 +71,7 @@ get_min(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::f
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_min(const boost::mpl::false_&, const boost::mpl::true_&, const boost::mpl::bool_<has_allocator>&) get_min(const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&, const std::integral_constant<bool, has_allocator>&)
{ {
// Unbounded and signed, never constexpr because there must be an allocator. // Unbounded and signed, never constexpr because there must be an allocator.
// There is no minimum value, just return 0: // There is no minimum value, just return 0:
@@ -81,7 +81,7 @@ get_min(const boost::mpl::false_&, const boost::mpl::true_&, const boost::mpl::b
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_min(const boost::mpl::false_&, const boost::mpl::false_&, const boost::mpl::bool_<has_allocator>&) get_min(const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&, const std::integral_constant<bool, has_allocator>&)
{ {
// Unbound and unsigned, never constexpr because there must be an allocator. // Unbound and unsigned, never constexpr because there must be an allocator.
static const boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> val(0u); static const boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> val(0u);
@@ -90,7 +90,7 @@ get_min(const boost::mpl::false_&, const boost::mpl::false_&, const boost::mpl::
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_max(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::true_&) get_max(const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&)
{ {
// Bounded and signed, no allocator, can be constexpr. // Bounded and signed, no allocator, can be constexpr.
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type;
@@ -106,7 +106,7 @@ get_max(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::tr
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_max(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::false_&) get_max(const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&)
{ {
// Bounded and signed, has an allocator, never constexpr. // Bounded and signed, has an allocator, never constexpr.
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type;
@@ -117,7 +117,7 @@ get_max(const boost::mpl::true_&, const boost::mpl::true_&, const boost::mpl::fa
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline BOOST_CXX14_CONSTEXPR_IF_DETECTION boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_max(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::true_&) get_max(const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&)
{ {
// Bound and unsigned, no allocator so can be constexpr: // Bound and unsigned, no allocator so can be constexpr:
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type;
@@ -133,7 +133,7 @@ get_max(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::t
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_max(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::false_&) get_max(const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&)
{ {
// Bound and unsigned, has an allocator so can never be constexpr: // Bound and unsigned, has an allocator so can never be constexpr:
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> result_type;
@@ -144,7 +144,7 @@ get_max(const boost::mpl::true_&, const boost::mpl::false_&, const boost::mpl::f
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_max(const boost::mpl::false_&, const boost::mpl::true_&, const boost::mpl::bool_<has_allocator>&) get_max(const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&, const std::integral_constant<bool, has_allocator>&)
{ {
// Unbounded and signed. // Unbounded and signed.
// There is no maximum value, just return 0: // There is no maximum value, just return 0:
@@ -154,7 +154,7 @@ get_max(const boost::mpl::false_&, const boost::mpl::true_&, const boost::mpl::b
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates, bool has_allocator>
inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> inline boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates>
get_max(const boost::mpl::false_&, const boost::mpl::false_&, const boost::mpl::bool_<has_allocator>&) get_max(const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&, const std::integral_constant<bool, has_allocator>&)
{ {
// Unbound and unsigned: // Unbound and unsigned:
static const boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> val(0u); static const boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ExpressionTemplates> val(0u);
@@ -190,12 +190,12 @@ class numeric_limits<boost::multiprecision::number<boost::multiprecision::cpp_in
static BOOST_CXX14_CONSTEXPR_IF_DETECTION number_type(min)() static BOOST_CXX14_CONSTEXPR_IF_DETECTION number_type(min)()
{ {
init.do_nothing(); init.do_nothing();
return detail::get_min<MinBits, MaxBits, SignType, Checked, Allocator, ExpressionTemplates>(boost::multiprecision::backends::is_fixed_precision<backend_type>(), boost::multiprecision::is_signed_number<backend_type>(), boost::mpl::bool_<std::is_void<Allocator>::value>()); return detail::get_min<MinBits, MaxBits, SignType, Checked, Allocator, ExpressionTemplates>(boost::multiprecision::backends::is_fixed_precision<backend_type>(), boost::multiprecision::is_signed_number<backend_type>(), std::integral_constant<bool, std::is_void<Allocator>::value>());
} }
static BOOST_CXX14_CONSTEXPR_IF_DETECTION number_type(max)() static BOOST_CXX14_CONSTEXPR_IF_DETECTION number_type(max)()
{ {
init.do_nothing(); init.do_nothing();
return detail::get_max<MinBits, MaxBits, SignType, Checked, Allocator, ExpressionTemplates>(boost::multiprecision::backends::is_fixed_precision<backend_type>(), boost::multiprecision::is_signed_number<backend_type>(), boost::mpl::bool_<std::is_void<Allocator>::value>()); return detail::get_max<MinBits, MaxBits, SignType, Checked, Allocator, ExpressionTemplates>(boost::multiprecision::backends::is_fixed_precision<backend_type>(), boost::multiprecision::is_signed_number<backend_type>(), std::integral_constant<bool, std::is_void<Allocator>::value>());
} }
static BOOST_CXX14_CONSTEXPR_IF_DETECTION number_type lowest() { return (min)(); } static BOOST_CXX14_CONSTEXPR_IF_DETECTION number_type lowest() { return (min)(); }
static constexpr int digits = boost::multiprecision::backends::max_precision<backend_type>::value == UINT_MAX ? INT_MAX : boost::multiprecision::backends::max_precision<backend_type>::value; static constexpr int digits = boost::multiprecision::backends::max_precision<backend_type>::value == UINT_MAX ? INT_MAX : boost::multiprecision::backends::max_precision<backend_type>::value;
@@ -38,7 +38,7 @@ struct numeric_limits_workaround<R, false>
}; };
template <class R, class CppInt> template <class R, class CppInt>
BOOST_MP_CXX14_CONSTEXPR void check_in_range(const CppInt& val, const mpl::int_<checked>&) BOOST_MP_CXX14_CONSTEXPR void check_in_range(const CppInt& val, const std::integral_constant<int, checked>&)
{ {
typedef typename boost::multiprecision::detail::canonical<R, CppInt>::type cast_type; typedef typename boost::multiprecision::detail::canonical<R, CppInt>::type cast_type;
@@ -56,7 +56,7 @@ BOOST_MP_CXX14_CONSTEXPR void check_in_range(const CppInt& val, const mpl::int_<
} }
} }
template <class R, class CppInt> template <class R, class CppInt>
inline BOOST_MP_CXX14_CONSTEXPR void check_in_range(const CppInt& /*val*/, const mpl::int_<unchecked>&) BOOST_NOEXCEPT {} inline BOOST_MP_CXX14_CONSTEXPR void check_in_range(const CppInt& /*val*/, const std::integral_constant<int, unchecked>&) BOOST_NOEXCEPT {}
inline BOOST_MP_CXX14_CONSTEXPR void check_is_negative(const std::integral_constant<bool, true>&) BOOST_NOEXCEPT {} inline BOOST_MP_CXX14_CONSTEXPR void check_is_negative(const std::integral_constant<bool, true>&) BOOST_NOEXCEPT {}
inline void check_is_negative(const std::integral_constant<bool, false>&) inline void check_is_negative(const std::integral_constant<bool, false>&)
@@ -79,7 +79,7 @@ template <class R, unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignTy
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<R>::value && !is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value, void>::type inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<R>::value && !is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value, void>::type
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend) eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend)
{ {
typedef mpl::int_<Checked1> checked_type; typedef std::integral_constant<int, Checked1> checked_type;
check_in_range<R>(backend, checked_type()); check_in_range<R>(backend, checked_type());
BOOST_IF_CONSTEXPR(numeric_limits_workaround<R>::digits < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits) BOOST_IF_CONSTEXPR(numeric_limits_workaround<R>::digits < cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::limb_bits)
@@ -1111,11 +1111,11 @@ eval_lcm(cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& r
result.normalize(); // result may overflow the specified number of bits result.normalize(); // result may overflow the specified number of bits
} }
inline void conversion_overflow(const mpl::int_<checked>&) inline void conversion_overflow(const std::integral_constant<int, checked>&)
{ {
BOOST_THROW_EXCEPTION(std::overflow_error("Overflow in conversion to narrower type")); BOOST_THROW_EXCEPTION(std::overflow_error("Overflow in conversion to narrower type"));
} }
inline BOOST_MP_CXX14_CONSTEXPR void conversion_overflow(const mpl::int_<unchecked>&) {} inline BOOST_MP_CXX14_CONSTEXPR void conversion_overflow(const std::integral_constant<int, unchecked>&) {}
template <class R, unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1> template <class R, unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if< inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<
@@ -25,13 +25,13 @@ using namespace boost::multiprecision;
using namespace boost::multiprecision::backends; using namespace boost::multiprecision::backends;
template <class T> template <class T>
struct is_binary_archive : public mpl::false_ struct is_binary_archive : public std::integral_constant<bool, false>
{}; {};
template <> template <>
struct is_binary_archive<boost::archive::binary_oarchive> : public mpl::true_ struct is_binary_archive<boost::archive::binary_oarchive> : public std::integral_constant<bool, true>
{}; {};
template <> template <>
struct is_binary_archive<boost::archive::binary_iarchive> : public mpl::true_ struct is_binary_archive<boost::archive::binary_iarchive> : public std::integral_constant<bool, true>
{}; {};
// //
@@ -41,7 +41,7 @@ struct is_binary_archive<boost::archive::binary_iarchive> : public mpl::true_
// Binary or not archive. // Binary or not archive.
// //
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&, mpl::false_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, false> const&, std::integral_constant<bool, false> const&, std::integral_constant<bool, false> const&)
{ {
// Load. // Load.
// Non-trivial. // Non-trivial.
@@ -72,7 +72,7 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&,
val.normalize(); val.normalize();
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&, mpl::false_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, true> const&, std::integral_constant<bool, false> const&, std::integral_constant<bool, false> const&)
{ {
// Store. // Store.
// Non-trivial. // Non-trivial.
@@ -97,7 +97,7 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&,
} }
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&, mpl::false_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, false> const&, std::integral_constant<bool, true> const&, std::integral_constant<bool, false> const&)
{ {
// Load. // Load.
// Trivial. // Trivial.
@@ -119,7 +119,7 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&,
val.negate(); val.negate();
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, mpl::false_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, true> const&, std::integral_constant<bool, true> const&, std::integral_constant<bool, false> const&)
{ {
// Store. // Store.
// Trivial. // Trivial.
@@ -137,7 +137,7 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, m
} }
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&, mpl::true_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, false> const&, std::integral_constant<bool, false> const&, std::integral_constant<bool, true> const&)
{ {
// Load. // Load.
// Non-trivial. // Non-trivial.
@@ -153,7 +153,7 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::false_ const&,
val.normalize(); val.normalize();
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&, mpl::true_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, true> const&, std::integral_constant<bool, false> const&, std::integral_constant<bool, true> const&)
{ {
// Store. // Store.
// Non-trivial. // Non-trivial.
@@ -165,7 +165,7 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::false_ const&,
ar.save_binary(val.limbs(), c * sizeof(limb_type)); ar.save_binary(val.limbs(), c * sizeof(limb_type));
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&, mpl::true_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, false> const&, std::integral_constant<bool, true> const&, std::integral_constant<bool, true> const&)
{ {
// Load. // Load.
// Trivial. // Trivial.
@@ -177,7 +177,7 @@ void do_serialize(Archive& ar, Int& val, mpl::false_ const&, mpl::true_ const&,
val.negate(); val.negate();
} }
template <class Archive, class Int> template <class Archive, class Int>
void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, mpl::true_ const&) void do_serialize(Archive& ar, Int& val, std::integral_constant<bool, true> const&, std::integral_constant<bool, true> const&, std::integral_constant<bool, true> const&)
{ {
// Store. // Store.
// Trivial. // Trivial.
@@ -192,9 +192,10 @@ void do_serialize(Archive& ar, Int& val, mpl::true_ const&, mpl::true_ const&, m
template <class Archive, unsigned MinBits, unsigned MaxBits, mp::cpp_integer_type SignType, mp::cpp_int_check_type Checked, class Allocator> template <class Archive, unsigned MinBits, unsigned MaxBits, mp::cpp_integer_type SignType, mp::cpp_int_check_type Checked, class Allocator>
void serialize(Archive& ar, mp::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& val, const unsigned int /*version*/) void serialize(Archive& ar, mp::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& val, const unsigned int /*version*/)
{ {
typedef typename Archive::is_saving save_tag; typedef typename Archive::is_saving archive_save_tag;
typedef mpl::bool_<mp::backends::is_trivial_cpp_int<mp::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value> trivial_tag; typedef std::integral_constant<bool, archive_save_tag::value> save_tag;
typedef typename cpp_int_detail::is_binary_archive<Archive>::type binary_tag; typedef std::integral_constant<bool, mp::backends::is_trivial_cpp_int<mp::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value> trivial_tag;
typedef typename cpp_int_detail::is_binary_archive<Archive>::type binary_tag;
// Just dispatch to the correct method: // Just dispatch to the correct method:
cpp_int_detail::do_serialize(ar, val, save_tag(), trivial_tag(), binary_tag()); cpp_int_detail::do_serialize(ar, val, save_tag(), trivial_tag(), binary_tag());
+46 -46
View File
@@ -42,13 +42,13 @@ inline BOOST_MP_CXX14_CONSTEXPR unsigned find_msb_default(Unsigned mask)
} }
template <class Unsigned> template <class Unsigned>
inline BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask, const mpl::int_<0>&) inline BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask, const std::integral_constant<int, 0>&)
{ {
return find_lsb_default(mask); return find_lsb_default(mask);
} }
template <class Unsigned> template <class Unsigned>
inline BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask, const mpl::int_<0>&) inline BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask, const std::integral_constant<int, 0>&)
{ {
return find_msb_default(mask); return find_msb_default(mask);
} }
@@ -57,14 +57,14 @@ inline BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask, const mpl::int_
#pragma intrinsic(_BitScanForward, _BitScanReverse) #pragma intrinsic(_BitScanForward, _BitScanReverse)
BOOST_FORCEINLINE unsigned find_lsb(unsigned long mask, const mpl::int_<1>&) BOOST_FORCEINLINE unsigned find_lsb(unsigned long mask, const std::integral_constant<int, 1>&)
{ {
unsigned long result; unsigned long result;
_BitScanForward(&result, mask); _BitScanForward(&result, mask);
return result; return result;
} }
BOOST_FORCEINLINE unsigned find_msb(unsigned long mask, const mpl::int_<1>&) BOOST_FORCEINLINE unsigned find_msb(unsigned long mask, const std::integral_constant<int, 1>&)
{ {
unsigned long result; unsigned long result;
_BitScanReverse(&result, mask); _BitScanReverse(&result, mask);
@@ -74,14 +74,14 @@ BOOST_FORCEINLINE unsigned find_msb(unsigned long mask, const mpl::int_<1>&)
#pragma intrinsic(_BitScanForward64, _BitScanReverse64) #pragma intrinsic(_BitScanForward64, _BitScanReverse64)
BOOST_FORCEINLINE unsigned find_lsb(unsigned __int64 mask, const mpl::int_<2>&) BOOST_FORCEINLINE unsigned find_lsb(unsigned __int64 mask, const std::integral_constant<int, 2>&)
{ {
unsigned long result; unsigned long result;
_BitScanForward64(&result, mask); _BitScanForward64(&result, mask);
return result; return result;
} }
template <class Unsigned> template <class Unsigned>
BOOST_FORCEINLINE unsigned find_msb(Unsigned mask, const mpl::int_<2>&) BOOST_FORCEINLINE unsigned find_msb(Unsigned mask, const std::integral_constant<int, 2>&)
{ {
unsigned long result; unsigned long result;
_BitScanReverse64(&result, mask); _BitScanReverse64(&result, mask);
@@ -95,14 +95,14 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask)
typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type; typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type;
typedef typename std::conditional< typedef typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned long), sizeof(Unsigned) <= sizeof(unsigned long),
mpl::int_<1>, std::integral_constant<int, 1>,
#ifdef _M_X64 #ifdef _M_X64
typename std::conditional< typename std::conditional<
sizeof(Unsigned) <= sizeof(__int64), sizeof(Unsigned) <= sizeof(__int64),
mpl::int_<2>, std::integral_constant<int, 2>,
mpl::int_<0> >::type std::integral_constant<int, 0> >::type
#else #else
mpl::int_<0> std::integral_constant<int, 0>
#endif #endif
>::type tag_type; >::type tag_type;
#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION #ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
@@ -121,14 +121,14 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type; typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type;
typedef typename std::conditional< typedef typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned long), sizeof(Unsigned) <= sizeof(unsigned long),
mpl::int_<1>, std::integral_constant<int, 1>,
#ifdef _M_X64 #ifdef _M_X64
typename std::conditional< typename std::conditional<
sizeof(Unsigned) <= sizeof(__int64), sizeof(Unsigned) <= sizeof(__int64),
mpl::int_<2>, std::integral_constant<int, 2>,
mpl::int_<0> >::type std::integral_constant<int, 0> >::type
#else #else
mpl::int_<0> std::integral_constant<int, 0>
#endif #endif
>::type tag_type; >::type tag_type;
#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION #ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
@@ -143,27 +143,27 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
#elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__)) #elif defined(BOOST_GCC) || defined(__clang__) || (defined(BOOST_INTEL) && defined(__GNUC__))
BOOST_FORCEINLINE unsigned find_lsb(unsigned mask, mpl::int_<1> const&) BOOST_FORCEINLINE unsigned find_lsb(unsigned mask, std::integral_constant<int, 1> const&)
{ {
return __builtin_ctz(mask); return __builtin_ctz(mask);
} }
BOOST_FORCEINLINE unsigned find_lsb(unsigned long mask, mpl::int_<2> const&) BOOST_FORCEINLINE unsigned find_lsb(unsigned long mask, std::integral_constant<int, 2> const&)
{ {
return __builtin_ctzl(mask); return __builtin_ctzl(mask);
} }
BOOST_FORCEINLINE unsigned find_lsb(boost::ulong_long_type mask, mpl::int_<3> const&) BOOST_FORCEINLINE unsigned find_lsb(boost::ulong_long_type mask, std::integral_constant<int, 3> const&)
{ {
return __builtin_ctzll(mask); return __builtin_ctzll(mask);
} }
BOOST_FORCEINLINE unsigned find_msb(unsigned mask, mpl::int_<1> const&) BOOST_FORCEINLINE unsigned find_msb(unsigned mask, std::integral_constant<int, 1> const&)
{ {
return sizeof(unsigned) * CHAR_BIT - 1 - __builtin_clz(mask); return sizeof(unsigned) * CHAR_BIT - 1 - __builtin_clz(mask);
} }
BOOST_FORCEINLINE unsigned find_msb(unsigned long mask, mpl::int_<2> const&) BOOST_FORCEINLINE unsigned find_msb(unsigned long mask, std::integral_constant<int, 2> const&)
{ {
return sizeof(unsigned long) * CHAR_BIT - 1 - __builtin_clzl(mask); return sizeof(unsigned long) * CHAR_BIT - 1 - __builtin_clzl(mask);
} }
BOOST_FORCEINLINE unsigned find_msb(boost::ulong_long_type mask, mpl::int_<3> const&) BOOST_FORCEINLINE unsigned find_msb(boost::ulong_long_type mask, std::integral_constant<int, 3> const&)
{ {
return sizeof(boost::ulong_long_type) * CHAR_BIT - 1 - __builtin_clzll(mask); return sizeof(boost::ulong_long_type) * CHAR_BIT - 1 - __builtin_clzll(mask);
} }
@@ -171,7 +171,7 @@ BOOST_FORCEINLINE unsigned find_msb(boost::ulong_long_type mask, mpl::int_<3> co
__extension__ typedef unsigned __int128 uint128_type; __extension__ typedef unsigned __int128 uint128_type;
BOOST_FORCEINLINE unsigned find_msb(uint128_type mask, mpl::int_<0> const&) BOOST_FORCEINLINE unsigned find_msb(uint128_type mask, std::integral_constant<int, 0> const&)
{ {
union union
{ {
@@ -181,15 +181,15 @@ BOOST_FORCEINLINE unsigned find_msb(uint128_type mask, mpl::int_<0> const&)
val.v = mask; val.v = mask;
#if BOOST_ENDIAN_LITTLE_BYTE #if BOOST_ENDIAN_LITTLE_BYTE
if (val.sv[1]) if (val.sv[1])
return find_msb(val.sv[1], mpl::int_<3>()) + 64; return find_msb(val.sv[1], std::integral_constant<int, 3>()) + 64;
return find_msb(val.sv[0], mpl::int_<3>()); return find_msb(val.sv[0], std::integral_constant<int, 3>());
#else #else
if (val.sv[0]) if (val.sv[0])
return find_msb(val.sv[0], mpl::int_<3>()) + 64; return find_msb(val.sv[0], std::integral_constant<int, 3>()) + 64;
return find_msb(val.sv[1], mpl::int_<3>()); return find_msb(val.sv[1], std::integral_constant<int, 3>());
#endif #endif
} }
BOOST_FORCEINLINE unsigned find_lsb(uint128_type mask, mpl::int_<0> const&) BOOST_FORCEINLINE unsigned find_lsb(uint128_type mask, std::integral_constant<int, 0> const&)
{ {
union union
{ {
@@ -199,12 +199,12 @@ BOOST_FORCEINLINE unsigned find_lsb(uint128_type mask, mpl::int_<0> const&)
val.v = mask; val.v = mask;
#if BOOST_ENDIAN_LITTLE_BYTE #if BOOST_ENDIAN_LITTLE_BYTE
if (val.sv[0] == 0) if (val.sv[0] == 0)
return find_lsb(val.sv[1], mpl::int_<3>()) + 64; return find_lsb(val.sv[1], std::integral_constant<int, 3>()) + 64;
return find_lsb(val.sv[0], mpl::int_<3>()); return find_lsb(val.sv[0], std::integral_constant<int, 3>());
#else #else
if (val.sv[1] == 0) if (val.sv[1] == 0)
return find_lsb(val.sv[0], mpl::int_<3>()) + 64; return find_lsb(val.sv[0], std::integral_constant<int, 3>()) + 64;
return find_lsb(val.sv[1], mpl::int_<3>()); return find_lsb(val.sv[1], std::integral_constant<int, 3>());
#endif #endif
} }
#endif #endif
@@ -215,14 +215,14 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask)
typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type; typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type;
typedef typename std::conditional< typedef typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned), sizeof(Unsigned) <= sizeof(unsigned),
mpl::int_<1>, std::integral_constant<int, 1>,
typename std::conditional< typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned long), sizeof(Unsigned) <= sizeof(unsigned long),
mpl::int_<2>, std::integral_constant<int, 2>,
typename std::conditional< typename std::conditional<
sizeof(Unsigned) <= sizeof(boost::ulong_long_type), sizeof(Unsigned) <= sizeof(boost::ulong_long_type),
mpl::int_<3>, std::integral_constant<int, 3>,
mpl::int_<0> >::type>::type>::type tag_type; std::integral_constant<int, 0> >::type>::type>::type tag_type;
#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION #ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
if (BOOST_MP_IS_CONST_EVALUATED(mask)) if (BOOST_MP_IS_CONST_EVALUATED(mask))
{ {
@@ -238,14 +238,14 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type; typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type;
typedef typename std::conditional< typedef typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned), sizeof(Unsigned) <= sizeof(unsigned),
mpl::int_<1>, std::integral_constant<int, 1>,
typename std::conditional< typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned long), sizeof(Unsigned) <= sizeof(unsigned long),
mpl::int_<2>, std::integral_constant<int, 2>,
typename std::conditional< typename std::conditional<
sizeof(Unsigned) <= sizeof(boost::ulong_long_type), sizeof(Unsigned) <= sizeof(boost::ulong_long_type),
mpl::int_<3>, std::integral_constant<int, 3>,
mpl::int_<0> >::type>::type>::type tag_type; std::integral_constant<int, 0> >::type>::type>::type tag_type;
#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION #ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
if (BOOST_MP_IS_CONST_EVALUATED(mask)) if (BOOST_MP_IS_CONST_EVALUATED(mask))
{ {
@@ -256,11 +256,11 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
return find_msb(static_cast<ui_type>(mask), tag_type()); return find_msb(static_cast<ui_type>(mask), tag_type());
} }
#elif defined(BOOST_INTEL) #elif defined(BOOST_INTEL)
BOOST_FORCEINLINE unsigned find_lsb(unsigned mask, mpl::int_<1> const&) BOOST_FORCEINLINE unsigned find_lsb(unsigned mask, std::integral_constant<int, 1> const&)
{ {
return _bit_scan_forward(mask); return _bit_scan_forward(mask);
} }
BOOST_FORCEINLINE unsigned find_msb(unsigned mask, mpl::int_<1> const&) BOOST_FORCEINLINE unsigned find_msb(unsigned mask, std::integral_constant<int, 1> const&)
{ {
return _bit_scan_reverse(mask); return _bit_scan_reverse(mask);
} }
@@ -270,8 +270,8 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask)
typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type; typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type;
typedef typename std::conditional< typedef typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned), sizeof(Unsigned) <= sizeof(unsigned),
mpl::int_<1>, std::integral_constant<int, 1>,
mpl::int_<0> >::type tag_type; std::integral_constant<int, 0> >::type tag_type;
#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION #ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
if (BOOST_MP_IS_CONST_EVALUATED(mask)) if (BOOST_MP_IS_CONST_EVALUATED(mask))
{ {
@@ -287,8 +287,8 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type; typedef typename boost::multiprecision::detail::make_unsigned<Unsigned>::type ui_type;
typedef typename std::conditional< typedef typename std::conditional<
sizeof(Unsigned) <= sizeof(unsigned), sizeof(Unsigned) <= sizeof(unsigned),
mpl::int_<1>, std::integral_constant<int, 1>,
mpl::int_<0> >::type tag_type; std::integral_constant<int, 0> >::type tag_type;
#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION #ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
if (BOOST_MP_IS_CONST_EVALUATED(mask)) if (BOOST_MP_IS_CONST_EVALUATED(mask))
{ {
@@ -302,12 +302,12 @@ BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
template <class Unsigned> template <class Unsigned>
BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask) BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_lsb(Unsigned mask)
{ {
return find_lsb(mask, mpl::int_<0>()); return find_lsb(mask, std::integral_constant<int, 0>());
} }
template <class Unsigned> template <class Unsigned>
BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask) BOOST_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR unsigned find_msb(Unsigned mask)
{ {
return find_msb(mask, mpl::int_<0>()); return find_msb(mask, std::integral_constant<int, 0>());
} }
#endif #endif
@@ -12,8 +12,6 @@
#include <boost/math/special_functions/fpclassify.hpp> #include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/next.hpp> #include <boost/math/special_functions/next.hpp>
#include <boost/math/special_functions/hypot.hpp> #include <boost/math/special_functions/hypot.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/fold.hpp>
#include <cstdint> #include <cstdint>
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW #ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
#include <string_view> #include <string_view>
@@ -37,15 +35,15 @@ template <class T>
struct is_backend; struct is_backend;
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/); void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_floating_point>& /*to_type*/, const std::integral_constant<int, number_kind_integer>& /*from_type*/);
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/); void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_integer>& /*to_type*/, const std::integral_constant<int, number_kind_integer>& /*from_type*/);
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/); void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_floating_point>& /*to_type*/, const std::integral_constant<int, number_kind_floating_point>& /*from_type*/);
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/); void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_rational>& /*to_type*/, const std::integral_constant<int, number_kind_rational>& /*from_type*/);
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/); void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_rational>& /*to_type*/, const std::integral_constant<int, number_kind_integer>& /*from_type*/);
} // namespace detail } // namespace detail
@@ -786,13 +784,13 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_bitwise_xor(T& t, const U& u, const V&
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR void eval_increment(T& val) inline BOOST_MP_CXX14_CONSTEXPR void eval_increment(T& val)
{ {
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
eval_add(val, static_cast<ui_type>(1u)); eval_add(val, static_cast<ui_type>(1u));
} }
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR void eval_decrement(T& val) inline BOOST_MP_CXX14_CONSTEXPR void eval_decrement(T& val)
{ {
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
eval_subtract(val, static_cast<ui_type>(1u)); eval_subtract(val, static_cast<ui_type>(1u));
} }
@@ -813,18 +811,18 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_right_shift(T& result, const U& arg, c
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_is_zero(const T& val) inline BOOST_MP_CXX14_CONSTEXPR bool eval_is_zero(const T& val)
{ {
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
return val.compare(static_cast<ui_type>(0)) == 0; return val.compare(static_cast<ui_type>(0)) == 0;
} }
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR int eval_get_sign(const T& val) inline BOOST_MP_CXX14_CONSTEXPR int eval_get_sign(const T& val)
{ {
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
return val.compare(static_cast<ui_type>(0)); return val.compare(static_cast<ui_type>(0));
} }
template <class T, class V, class U> template <class T, class V, class U>
inline BOOST_MP_CXX14_CONSTEXPR void assign_components_imp(T& result, const V& v1, const U& v2, const mpl::int_<number_kind_rational>&) inline BOOST_MP_CXX14_CONSTEXPR void assign_components_imp(T& result, const V& v1, const U& v2, const std::integral_constant<int, number_kind_rational>&)
{ {
result = v1; result = v1;
T t; T t;
@@ -833,7 +831,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void assign_components_imp(T& result, const V& v
} }
template <class T, class V, class U, int N> template <class T, class V, class U, int N>
inline BOOST_MP_CXX14_CONSTEXPR void assign_components_imp(T& result, const V& v1, const U& v2, const mpl::int_<N>&) inline BOOST_MP_CXX14_CONSTEXPR void assign_components_imp(T& result, const V& v1, const U& v2, const std::integral_constant<int, N>&)
{ {
typedef typename component_type<number<T> >::type component_number_type; typedef typename component_type<number<T> >::type component_number_type;
@@ -868,7 +866,7 @@ template <class R, int b>
struct has_enough_bits struct has_enough_bits
{ {
template <class T> template <class T>
struct type : public mpl::bool_<!std::is_same<R, T>::value && (std::numeric_limits<T>::digits >= b)> struct type : public std::integral_constant<bool, !std::is_same<R, T>::value && (std::numeric_limits<T>::digits >= b)>
{}; {};
}; };
@@ -886,6 +884,18 @@ struct terminal
BOOST_MP_CXX14_CONSTEXPR operator R() const { return value; } BOOST_MP_CXX14_CONSTEXPR operator R() const { return value; }
}; };
template <class Tuple, int i, class T, bool = (i == std::tuple_size<Tuple>::value)>
struct find_index_of_type
{
static constexpr int value = std::is_same<T, typename std::tuple_element<i, Tuple>::type>::value ? i : find_index_of_type<Tuple, i + 1, T>::value;
};
template <class Tuple, int i, class T>
struct find_index_of_type<Tuple, i, T, true>
{
static constexpr int value = -1;
};
template <class R, class B> template <class R, class B>
struct calculate_next_larger_type struct calculate_next_larger_type
{ {
@@ -897,25 +907,9 @@ struct calculate_next_larger_type
boost::multiprecision::detail::is_unsigned<R>::value, boost::multiprecision::detail::is_unsigned<R>::value,
typename B::unsigned_types, typename B::unsigned_types,
typename B::float_types>::type>::type list_type; typename B::float_types>::type>::type list_type;
// A predicate to find a type with enough bits: static constexpr int start = find_index_of_type<list_type, 0, R>::value;
typedef typename has_enough_bits<R, std::numeric_limits<R>::digits>::template type<mpl::_> pred_type; static constexpr int index_of_type = boost::multiprecision::detail::find_index_of_large_enough_type<list_type, start + 1, std::numeric_limits<R>::digits>::value;
// See if the last type is in the list, if so we have to start after this: typedef typename boost::multiprecision::detail::dereference_tuple<index_of_type, list_type, terminal<R> >::type type;
typedef typename mpl::find_if<
list_type,
std::is_same<R, mpl::_> >::type start_last;
// Where we're starting from, either the start of the sequence or the last type found:
typedef typename std::conditional<std::is_same<start_last, typename mpl::end<list_type>::type>::value, typename mpl::begin<list_type>::type, start_last>::type start_seq;
// The range we're searching:
typedef mpl::iterator_range<start_seq, typename mpl::end<list_type>::type> range;
// Find the next type:
typedef typename mpl::find_if<
range,
pred_type>::type iter_type;
// Either the next type, or a "terminal" to indicate we've run out of types to search:
typedef typename mpl::eval_if_c<
std::is_same<typename mpl::end<list_type>::type, iter_type>::value,
mpl::identity<terminal<R> >,
mpl::deref<iter_type> >::type type;
}; };
template <class R, class T> template <class R, class T>
@@ -961,7 +955,7 @@ inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if< !boost::multiprecision:
} }
template <class R, class B> template <class R, class B>
inline void last_chance_eval_convert_to(terminal<R>* result, const B& backend, const mpl::false_&) inline void last_chance_eval_convert_to(terminal<R>* result, const B& backend, const std::integral_constant<bool, false>&)
{ {
// //
// We ran out of types to try for the conversion, try // We ran out of types to try for the conversion, try
@@ -985,7 +979,7 @@ inline void last_chance_eval_convert_to(terminal<R>* result, const B& backend, c
} }
template <class R, class B> template <class R, class B>
inline void last_chance_eval_convert_to(terminal<R>* result, const B& backend, const mpl::true_&) inline void last_chance_eval_convert_to(terminal<R>* result, const B& backend, const std::integral_constant<bool, true>&)
{ {
// //
// We ran out of types to try for the conversion, try // We ran out of types to try for the conversion, try
@@ -1014,7 +1008,7 @@ inline void last_chance_eval_convert_to(terminal<R>* result, const B& backend, c
template <class R, class B> template <class R, class B>
inline BOOST_MP_CXX14_CONSTEXPR void eval_convert_to(terminal<R>* result, const B& backend) inline BOOST_MP_CXX14_CONSTEXPR void eval_convert_to(terminal<R>* result, const B& backend)
{ {
typedef mpl::bool_<boost::multiprecision::detail::is_unsigned<R>::value && number_category<B>::value == number_kind_integer> tag_type; typedef std::integral_constant<bool, boost::multiprecision::detail::is_unsigned<R>::value && number_category<B>::value == number_kind_integer> tag_type;
last_chance_eval_convert_to(result, backend, tag_type()); last_chance_eval_convert_to(result, backend, tag_type());
} }
@@ -1074,7 +1068,7 @@ template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR void eval_abs(T& result, const U& arg) inline BOOST_MP_CXX14_CONSTEXPR void eval_abs(T& result, const U& arg)
{ {
typedef typename U::signed_types type_list; typedef typename U::signed_types type_list;
typedef typename mpl::front<type_list>::type front; typedef typename std::tuple_element<0, type_list>::type front;
result = arg; result = arg;
if (arg.compare(front(0)) < 0) if (arg.compare(front(0)) < 0)
result.negate(); result.negate();
@@ -1084,7 +1078,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_fabs(T& result, const U& arg)
{ {
static_assert(number_category<T>::value == number_kind_floating_point, "The fabs function is only valid for floating point types."); static_assert(number_category<T>::value == number_kind_floating_point, "The fabs function is only valid for floating point types.");
typedef typename U::signed_types type_list; typedef typename U::signed_types type_list;
typedef typename mpl::front<type_list>::type front; typedef typename std::tuple_element<0, type_list>::type front;
result = arg; result = arg;
if (arg.compare(front(0)) < 0) if (arg.compare(front(0)) < 0)
result.negate(); result.negate();
@@ -1811,7 +1805,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_real(To& to, const From& from)
template <class To, class From> template <class To, class From>
inline BOOST_MP_CXX14_CONSTEXPR void eval_imag(To& to, const From&) inline BOOST_MP_CXX14_CONSTEXPR void eval_imag(To& to, const From&)
{ {
typedef typename mpl::front<typename To::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename To::unsigned_types>::type ui_type;
to = ui_type(0); to = ui_type(0);
} }
@@ -53,7 +53,7 @@ std::string convert_to_string(Backend b, std::streamsize digits, std::ios_base::
using default_ops::eval_pow; using default_ops::eval_pow;
using default_ops::eval_subtract; using default_ops::eval_subtract;
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
typedef typename Backend::exponent_type exponent_type; typedef typename Backend::exponent_type exponent_type;
std::string result; std::string result;
@@ -196,7 +196,7 @@ void convert_from_string(Backend& b, const char* p)
using default_ops::eval_multiply; using default_ops::eval_multiply;
using default_ops::eval_pow; using default_ops::eval_pow;
typedef typename mpl::front<typename Backend::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename Backend::unsigned_types>::type ui_type;
b = ui_type(0); b = ui_type(0);
if (!p || (*p == 0)) if (!p || (*p == 0))
return; return;
@@ -10,7 +10,7 @@ template <class T>
void calc_log2(T& num, unsigned digits) void calc_log2(T& num, unsigned digits)
{ {
typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type; typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type;
typedef typename mpl::front<typename T::signed_types>::type si_type; typedef typename std::tuple_element<0, typename T::signed_types>::type si_type;
// //
// String value with 1100 digits: // String value with 1100 digits:
@@ -80,7 +80,7 @@ void calc_log2(T& num, unsigned digits)
template <class T> template <class T>
void calc_e(T& result, unsigned digits) void calc_e(T& result, unsigned digits)
{ {
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
// //
// 1100 digits in string form: // 1100 digits in string form:
// //
@@ -129,8 +129,8 @@ void calc_e(T& result, unsigned digits)
template <class T> template <class T>
void calc_pi(T& result, unsigned digits) void calc_pi(T& result, unsigned digits)
{ {
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
typedef typename mpl::front<typename T::float_types>::type real_type; typedef typename std::tuple_element<0, typename T::float_types>::type real_type;
// //
// 1100 digits in string form: // 1100 digits in string form:
// //
@@ -327,7 +327,7 @@ const T& get_constant_one_over_epsilon()
if ((digits != boost::multiprecision::detail::digits2<number<T> >::value())) if ((digits != boost::multiprecision::detail::digits2<number<T> >::value()))
{ {
#endif #endif
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
boost::multiprecision::detail::maybe_promote_precision(&result); boost::multiprecision::detail::maybe_promote_precision(&result);
result = static_cast<ui_type>(1u); result = static_cast<ui_type>(1u);
if(std::numeric_limits<number<T> >::is_specialized) if(std::numeric_limits<number<T> >::is_specialized)
@@ -102,7 +102,7 @@ void hyp0F0(T& H0F0, const T& x)
// http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric0F0/06/01/ // http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric0F0/06/01/
// There are no checks on input range or parameter boundaries. // There are no checks on input range or parameter boundaries.
typedef typename mpl::front<typename T::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename T::unsigned_types>::type ui_type;
BOOST_ASSERT(&H0F0 != &x); BOOST_ASSERT(&H0F0 != &x);
long tol = boost::multiprecision::detail::digits2<number<T, et_on> >::value(); long tol = boost::multiprecision::detail::digits2<number<T, et_on> >::value();
@@ -350,7 +350,7 @@ void eval_log(T& result, const T& arg)
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type; typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
typedef typename T::exponent_type exp_type; typedef typename T::exponent_type exp_type;
typedef typename boost::multiprecision::detail::canonical<exp_type, T>::type canonical_exp_type; typedef typename boost::multiprecision::detail::canonical<exp_type, T>::type canonical_exp_type;
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
int s = eval_signbit(arg); int s = eval_signbit(arg);
switch (eval_fpclassify(arg)) switch (eval_fpclassify(arg))
{ {
@@ -471,7 +471,7 @@ inline void eval_pow(T& result, const T& x, const T& a)
{ {
static_assert(number_category<T>::value == number_kind_floating_point, "The pow function is only valid for floating point types."); static_assert(number_category<T>::value == number_kind_floating_point, "The pow function is only valid for floating point types.");
typedef typename boost::multiprecision::detail::canonical<int, T>::type si_type; typedef typename boost::multiprecision::detail::canonical<int, T>::type si_type;
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
if ((&result == &x) || (&result == &a)) if ((&result == &x) || (&result == &a))
{ {
@@ -761,7 +761,7 @@ void eval_exp2(T& result, const T& arg)
eval_convert_to(&i, temp); eval_convert_to(&i, temp);
if (arg.compare(i) == 0) if (arg.compare(i) == 0)
{ {
temp = static_cast<typename mpl::front<typename T::unsigned_types>::type>(1u); temp = static_cast<typename std::tuple_element<0, typename T::unsigned_types>::type>(1u);
eval_ldexp(result, temp, i); eval_ldexp(result, temp, i);
return; return;
} }
@@ -774,7 +774,7 @@ void eval_exp2(T& result, const T& arg)
} }
BOOST_CATCH_END BOOST_CATCH_END
temp = static_cast<typename mpl::front<typename T::unsigned_types>::type>(2u); temp = static_cast<typename std::tuple_element<0, typename T::unsigned_types>::type>(2u);
eval_pow(result, temp, arg); eval_pow(result, temp, arg);
} }
@@ -811,7 +811,7 @@ template <class T>
void sinhcosh(const T& x, T* p_sinh, T* p_cosh) void sinhcosh(const T& x, T* p_sinh, T* p_cosh)
{ {
typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type; typedef typename boost::multiprecision::detail::canonical<unsigned, T>::type ui_type;
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
switch (eval_fpclassify(x)) switch (eval_fpclassify(x))
{ {
@@ -896,7 +896,7 @@ inline void eval_tanh(T& result, const T& x)
if ((eval_fpclassify(result) == FP_INFINITE) && (eval_fpclassify(c) == FP_INFINITE)) if ((eval_fpclassify(result) == FP_INFINITE) && (eval_fpclassify(c) == FP_INFINITE))
{ {
bool s = eval_signbit(result) != eval_signbit(c); bool s = eval_signbit(result) != eval_signbit(c);
result = static_cast<typename mpl::front<typename T::unsigned_types>::type>(1u); result = static_cast<typename std::tuple_element<0, typename T::unsigned_types>::type>(1u);
if (s) if (s)
result.negate(); result.negate();
return; return;
@@ -164,7 +164,7 @@ void eval_sin(T& result, const T& x)
typedef typename boost::multiprecision::detail::canonical<std::int32_t, T>::type si_type; typedef typename boost::multiprecision::detail::canonical<std::int32_t, T>::type si_type;
typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type; typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type;
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
switch (eval_fpclassify(x)) switch (eval_fpclassify(x))
{ {
@@ -563,7 +563,7 @@ void eval_asin(T& result, const T& x)
{ {
static_assert(number_category<T>::value == number_kind_floating_point, "The asin function is only valid for floating point types."); static_assert(number_category<T>::value == number_kind_floating_point, "The asin function is only valid for floating point types.");
typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type; typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type;
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
if (&result == &x) if (&result == &x)
{ {
@@ -736,7 +736,7 @@ inline void eval_acos(T& result, const T& x)
return; return;
} }
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
if (xx.compare(fp_type(1e-3)) < 0) if (xx.compare(fp_type(1e-3)) < 0)
{ {
@@ -820,7 +820,7 @@ void eval_atan(T& result, const T& x)
static_assert(number_category<T>::value == number_kind_floating_point, "The atan function is only valid for floating point types."); static_assert(number_category<T>::value == number_kind_floating_point, "The atan function is only valid for floating point types.");
typedef typename boost::multiprecision::detail::canonical<std::int32_t, T>::type si_type; typedef typename boost::multiprecision::detail::canonical<std::int32_t, T>::type si_type;
typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type; typedef typename boost::multiprecision::detail::canonical<std::uint32_t, T>::type ui_type;
typedef typename mpl::front<typename T::float_types>::type fp_type; typedef typename std::tuple_element<0, typename T::float_types>::type fp_type;
switch (eval_fpclassify(x)) switch (eval_fpclassify(x))
{ {
@@ -27,7 +27,7 @@ inline To do_cast(const number<B, et>& from)
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_floating_point>& /*to_type*/, const std::integral_constant<int, number_kind_integer>& /*from_type*/)
{ {
using default_ops::eval_add; using default_ops::eval_add;
using default_ops::eval_bitwise_and; using default_ops::eval_bitwise_and;
@@ -75,7 +75,7 @@ void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_integer>& /*to_type*/, const std::integral_constant<int, number_kind_integer>& /*from_type*/)
{ {
using default_ops::eval_bitwise_and; using default_ops::eval_bitwise_and;
using default_ops::eval_bitwise_or; using default_ops::eval_bitwise_or;
@@ -123,7 +123,7 @@ void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_floating_point>& /*to_type*/, const std::integral_constant<int, number_kind_floating_point>& /*from_type*/)
{ {
#ifdef BOOST_MSVC #ifdef BOOST_MSVC
#pragma warning(push) #pragma warning(push)
@@ -214,7 +214,7 @@ void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_rational>& /*to_type*/, const std::integral_constant<int, number_kind_rational>& /*from_type*/)
{ {
typedef typename component_type<number<To> >::type to_component_type; typedef typename component_type<number<To> >::type to_component_type;
@@ -225,7 +225,7 @@ void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_rational>& /*to_type*/, const std::integral_constant<int, number_kind_integer>& /*from_type*/)
{ {
typedef typename component_type<number<To> >::type to_component_type; typedef typename component_type<number<To> >::type to_component_type;
@@ -273,7 +273,7 @@ R safe_convert_to_float(const LargeInteger& i)
template <class To, class Integer> template <class To, class Integer>
inline typename std::enable_if<!(is_number<To>::value || std::is_floating_point<To>::value)>::type inline typename std::enable_if<!(is_number<To>::value || std::is_floating_point<To>::value)>::type
generic_convert_rational_to_float_imp(To& result, const Integer& n, const Integer& d, const mpl::true_&) generic_convert_rational_to_float_imp(To& result, const Integer& n, const Integer& d, const std::integral_constant<bool, true>&)
{ {
// //
// If we get here, then there's something about one type or the other // If we get here, then there's something about one type or the other
@@ -286,7 +286,7 @@ generic_convert_rational_to_float_imp(To& result, const Integer& n, const Intege
} }
template <class To, class Integer> template <class To, class Integer>
inline typename std::enable_if<is_number<To>::value || std::is_floating_point<To>::value>::type inline typename std::enable_if<is_number<To>::value || std::is_floating_point<To>::value>::type
generic_convert_rational_to_float_imp(To& result, const Integer& n, const Integer& d, const mpl::true_&) generic_convert_rational_to_float_imp(To& result, const Integer& n, const Integer& d, const std::integral_constant<bool, true>&)
{ {
// //
// If we get here, then there's something about one type or the other // If we get here, then there's something about one type or the other
@@ -300,7 +300,7 @@ generic_convert_rational_to_float_imp(To& result, const Integer& n, const Intege
template <class To, class Integer> template <class To, class Integer>
typename std::enable_if<is_number<To>::value || std::is_floating_point<To>::value>::type typename std::enable_if<is_number<To>::value || std::is_floating_point<To>::value>::type
generic_convert_rational_to_float_imp(To& result, Integer& num, Integer& denom, const mpl::false_&) generic_convert_rational_to_float_imp(To& result, Integer& num, Integer& denom, const std::integral_constant<bool, false>&)
{ {
// //
// If we get here, then the precision of type To is known, and the integer type is unbounded // If we get here, then the precision of type To is known, and the integer type is unbounded
@@ -361,7 +361,7 @@ generic_convert_rational_to_float_imp(To& result, Integer& num, Integer& denom,
} }
template <class To, class Integer> template <class To, class Integer>
inline typename std::enable_if<!(is_number<To>::value || std::is_floating_point<To>::value)>::type inline typename std::enable_if<!(is_number<To>::value || std::is_floating_point<To>::value)>::type
generic_convert_rational_to_float_imp(To& result, Integer& num, Integer& denom, const mpl::false_& tag) generic_convert_rational_to_float_imp(To& result, Integer& num, Integer& denom, const std::integral_constant<bool, false>& tag)
{ {
number<To> t; number<To> t;
generic_convert_rational_to_float_imp(t, num, denom, tag); generic_convert_rational_to_float_imp(t, num, denom, tag);
@@ -381,22 +381,22 @@ inline void generic_convert_rational_to_float(To& result, const From& f)
typedef typename std::conditional<is_number<From>::value, From, number<From> >::type actual_from_type; typedef typename std::conditional<is_number<From>::value, From, number<From> >::type actual_from_type;
typedef typename std::conditional<is_number<To>::value || std::is_floating_point<To>::value, To, number<To> >::type actual_to_type; typedef typename std::conditional<is_number<To>::value || std::is_floating_point<To>::value, To, number<To> >::type actual_to_type;
typedef typename component_type<actual_from_type>::type integer_type; typedef typename component_type<actual_from_type>::type integer_type;
typedef mpl::bool_<!std::numeric_limits<integer_type>::is_specialized || std::numeric_limits<integer_type>::is_bounded || !std::numeric_limits<actual_to_type>::is_specialized || !std::numeric_limits<actual_to_type>::is_bounded || (std::numeric_limits<actual_to_type>::radix != 2)> dispatch_tag; typedef std::integral_constant<bool, !std::numeric_limits<integer_type>::is_specialized || std::numeric_limits<integer_type>::is_bounded || !std::numeric_limits<actual_to_type>::is_specialized || !std::numeric_limits<actual_to_type>::is_bounded || (std::numeric_limits<actual_to_type>::radix != 2)> dispatch_tag;
integer_type n(numerator(static_cast<actual_from_type>(f))), d(denominator(static_cast<actual_from_type>(f))); integer_type n(numerator(static_cast<actual_from_type>(f))), d(denominator(static_cast<actual_from_type>(f)));
generic_convert_rational_to_float_imp(result, n, d, dispatch_tag()); generic_convert_rational_to_float_imp(result, n, d, dispatch_tag());
} }
template <class To, class From> template <class To, class From>
inline void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) inline void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_floating_point>& /*to_type*/, const std::integral_constant<int, number_kind_rational>& /*from_type*/)
{ {
generic_convert_rational_to_float(to, from); generic_convert_rational_to_float(to, from);
} }
template <class To, class From> template <class To, class From>
void generic_interconvert_float2rational(To& to, const From& from, const mpl::int_<2>& /*radix*/) void generic_interconvert_float2rational(To& to, const From& from, const std::integral_constant<int, 2>& /*radix*/)
{ {
typedef typename mpl::front<typename To::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename To::unsigned_types>::type ui_type;
static const int shift = std::numeric_limits<boost::long_long_type>::digits; static const int shift = std::numeric_limits<boost::long_long_type>::digits;
typename From::exponent_type e; typename From::exponent_type e;
typename component_type<number<To> >::type num, denom; typename component_type<number<To> >::type num, denom;
@@ -420,14 +420,14 @@ void generic_interconvert_float2rational(To& to, const From& from, const mpl::in
} }
template <class To, class From, int Radix> template <class To, class From, int Radix>
void generic_interconvert_float2rational(To& to, const From& from, const mpl::int_<Radix>& /*radix*/) void generic_interconvert_float2rational(To& to, const From& from, const std::integral_constant<int, Radix>& /*radix*/)
{ {
// //
// This is almost the same as the binary case above, but we have to use // This is almost the same as the binary case above, but we have to use
// scalbn and ilogb rather than ldexp and frexp, we also only extract // scalbn and ilogb rather than ldexp and frexp, we also only extract
// one Radix digit at a time which is terribly inefficient! // one Radix digit at a time which is terribly inefficient!
// //
typedef typename mpl::front<typename To::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename To::unsigned_types>::type ui_type;
typename From::exponent_type e; typename From::exponent_type e;
typename component_type<number<To> >::type num, denom; typename component_type<number<To> >::type num, denom;
number<From> val(from); number<From> val(from);
@@ -461,13 +461,13 @@ void generic_interconvert_float2rational(To& to, const From& from, const mpl::in
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_rational>& /*to_type*/, const std::integral_constant<int, number_kind_floating_point>& /*from_type*/)
{ {
generic_interconvert_float2rational(to, from, mpl::int_<std::numeric_limits<number<From> >::radix>()); generic_interconvert_float2rational(to, from, std::integral_constant<int, std::numeric_limits<number<From> >::radix>());
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_integer>& /*to_type*/, const std::integral_constant<int, number_kind_rational>& /*from_type*/)
{ {
number<From> t(from); number<From> t(from);
number<To> result(numerator(t) / denominator(t)); number<To> result(numerator(t) / denominator(t));
@@ -475,7 +475,7 @@ void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_
} }
template <class To, class From> template <class To, class From>
void generic_interconvert_float2int(To& to, const From& from, const mpl::int_<2>& /*radix*/) void generic_interconvert_float2int(To& to, const From& from, const std::integral_constant<int, 2>& /*radix*/)
{ {
typedef typename From::exponent_type exponent_type; typedef typename From::exponent_type exponent_type;
static const exponent_type shift = std::numeric_limits<boost::long_long_type>::digits; static const exponent_type shift = std::numeric_limits<boost::long_long_type>::digits;
@@ -505,7 +505,7 @@ void generic_interconvert_float2int(To& to, const From& from, const mpl::int_<2>
} }
template <class To, class From, int Radix> template <class To, class From, int Radix>
void generic_interconvert_float2int(To& to, const From& from, const mpl::int_<Radix>& /*radix*/) void generic_interconvert_float2int(To& to, const From& from, const std::integral_constant<int, Radix>& /*radix*/)
{ {
// //
// This is almost the same as the binary case above, but we have to use // This is almost the same as the binary case above, but we have to use
@@ -530,13 +530,13 @@ void generic_interconvert_float2int(To& to, const From& from, const mpl::int_<Ra
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_integer>& /*to_type*/, const std::integral_constant<int, number_kind_floating_point>& /*from_type*/)
{ {
generic_interconvert_float2int(to, from, mpl::int_<std::numeric_limits<number<From> >::radix>()); generic_interconvert_float2int(to, from, std::integral_constant<int, std::numeric_limits<number<From> >::radix>());
} }
template <class To, class From, class tag> template <class To, class From, class tag>
void generic_interconvert_complex_to_scalar(To& to, const From& from, const mpl::true_&, const tag&) void generic_interconvert_complex_to_scalar(To& to, const From& from, const std::integral_constant<bool, true>&, const tag&)
{ {
// We just want the real part, and "to" is the correct type already: // We just want the real part, and "to" is the correct type already:
eval_real(to, from); eval_real(to, from);
@@ -547,7 +547,7 @@ void generic_interconvert_complex_to_scalar(To& to, const From& from, const mpl:
BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert imaginary number to scalar.")); BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert imaginary number to scalar."));
} }
template <class To, class From> template <class To, class From>
void generic_interconvert_complex_to_scalar(To& to, const From& from, const mpl::false_&, const mpl::true_&) void generic_interconvert_complex_to_scalar(To& to, const From& from, const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&)
{ {
typedef typename component_type<number<From> >::type component_number; typedef typename component_type<number<From> >::type component_number;
typedef typename component_number::backend_type component_backend; typedef typename component_number::backend_type component_backend;
@@ -555,11 +555,11 @@ void generic_interconvert_complex_to_scalar(To& to, const From& from, const mpl:
// Get the real part and copy-construct the result from it: // Get the real part and copy-construct the result from it:
// //
component_backend r; component_backend r;
generic_interconvert_complex_to_scalar(r, from, mpl::true_(), mpl::true_()); generic_interconvert_complex_to_scalar(r, from, std::integral_constant<bool, true>(), std::integral_constant<bool, true>());
to = r; to = r;
} }
template <class To, class From> template <class To, class From>
void generic_interconvert_complex_to_scalar(To& to, const From& from, const mpl::false_&, const mpl::false_&) void generic_interconvert_complex_to_scalar(To& to, const From& from, const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&)
{ {
typedef typename component_type<number<From> >::type component_number; typedef typename component_type<number<From> >::type component_number;
typedef typename component_number::backend_type component_backend; typedef typename component_number::backend_type component_backend;
@@ -567,25 +567,25 @@ void generic_interconvert_complex_to_scalar(To& to, const From& from, const mpl:
// Get the real part and use a generic_interconvert to type To: // Get the real part and use a generic_interconvert to type To:
// //
component_backend r; component_backend r;
generic_interconvert_complex_to_scalar(r, from, mpl::true_(), mpl::true_()); generic_interconvert_complex_to_scalar(r, from, std::integral_constant<bool, true>(), std::integral_constant<bool, true>());
generic_interconvert(to, r, mpl::int_<number_category<To>::value>(), mpl::int_<number_category<To>::value>()); generic_interconvert(to, r, std::integral_constant<int, number_category<To>::value>(), std::integral_constant<int, number_category<To>::value>());
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_complex>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_floating_point>& /*to_type*/, const std::integral_constant<int, number_kind_complex>& /*from_type*/)
{ {
typedef typename component_type<number<From> >::type component_number; typedef typename component_type<number<From> >::type component_number;
typedef typename component_number::backend_type component_backend; typedef typename component_number::backend_type component_backend;
generic_interconvert_complex_to_scalar(to, from, mpl::bool_<std::is_same<component_backend, To>::value>(), mpl::bool_<std::is_constructible<To, const component_backend&>::value>()); generic_interconvert_complex_to_scalar(to, from, std::integral_constant<bool, std::is_same<component_backend, To>::value>(), std::integral_constant<bool, std::is_constructible<To, const component_backend&>::value>());
} }
template <class To, class From> template <class To, class From>
void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_complex>& /*from_type*/) void generic_interconvert(To& to, const From& from, const std::integral_constant<int, number_kind_integer>& /*to_type*/, const std::integral_constant<int, number_kind_complex>& /*from_type*/)
{ {
typedef typename component_type<number<From> >::type component_number; typedef typename component_type<number<From> >::type component_number;
typedef typename component_number::backend_type component_backend; typedef typename component_number::backend_type component_backend;
generic_interconvert_complex_to_scalar(to, from, mpl::bool_<std::is_same<component_backend, To>::value>(), mpl::bool_<std::is_constructible<To, const component_backend&>::value>()); generic_interconvert_complex_to_scalar(to, from, std::integral_constant<bool, std::is_same<component_backend, To>::value>(), std::integral_constant<bool, std::is_constructible<To, const component_backend&>::value>());
} }
} }
@@ -106,7 +106,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void eval_gcd(B& result, const B& a, const B& b)
template <class B> template <class B>
inline BOOST_MP_CXX14_CONSTEXPR void eval_lcm(B& result, const B& a, const B& b) inline BOOST_MP_CXX14_CONSTEXPR void eval_lcm(B& result, const B& a, const B& b)
{ {
typedef typename mpl::front<typename B::unsigned_types>::type ui_type; typedef typename std::tuple_element<0, typename B::unsigned_types>::type ui_type;
B t; B t;
eval_gcd(t, a, b); eval_gcd(t, a, b);
@@ -272,7 +272,7 @@ struct double_precision_type
// check the value is positive: // check the value is positive:
// //
template <class Backend> template <class Backend>
inline BOOST_MP_CXX14_CONSTEXPR void check_sign_of_backend(const Backend& v, const mpl::true_) inline BOOST_MP_CXX14_CONSTEXPR void check_sign_of_backend(const Backend& v, const std::integral_constant<bool, true>)
{ {
if (eval_get_sign(v) < 0) if (eval_get_sign(v) < 0)
{ {
@@ -280,7 +280,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void check_sign_of_backend(const Backend& v, con
} }
} }
template <class Backend> template <class Backend>
inline BOOST_MP_CXX14_CONSTEXPR void check_sign_of_backend(const Backend&, const mpl::false_) {} inline BOOST_MP_CXX14_CONSTEXPR void check_sign_of_backend(const Backend&, const std::integral_constant<bool, false>) {}
// //
// Calculate (a^p)%c: // Calculate (a^p)%c:
// //
@@ -296,7 +296,7 @@ BOOST_MP_CXX14_CONSTEXPR void eval_powm(Backend& result, const Backend& a, const
typedef typename double_precision_type<Backend>::type double_type; typedef typename double_precision_type<Backend>::type double_type;
typedef typename boost::multiprecision::detail::canonical<unsigned char, double_type>::type ui_type; typedef typename boost::multiprecision::detail::canonical<unsigned char, double_type>::type ui_type;
check_sign_of_backend(p, mpl::bool_<std::numeric_limits<number<Backend> >::is_signed>()); check_sign_of_backend(p, std::integral_constant<bool, std::numeric_limits<number<Backend> >::is_signed>());
double_type x, y(a), b(p), t; double_type x, y(a), b(p), t;
x = ui_type(1u); x = ui_type(1u);
@@ -330,7 +330,7 @@ BOOST_MP_CXX14_CONSTEXPR void eval_powm(Backend& result, const Backend& a, const
using default_ops::eval_multiply; using default_ops::eval_multiply;
using default_ops::eval_right_shift; using default_ops::eval_right_shift;
check_sign_of_backend(p, mpl::bool_<std::numeric_limits<number<Backend> >::is_signed>()); check_sign_of_backend(p, std::integral_constant<bool, std::numeric_limits<number<Backend> >::is_signed>());
if (eval_get_sign(p) < 0) if (eval_get_sign(p) < 0)
{ {
@@ -292,7 +292,7 @@ namespace boost {
{ {
number<B, et_off> result(a); number<B, et_off> result(a);
using default_ops::eval_left_shift; using default_ops::eval_left_shift;
detail::check_shift_range(b, mpl::bool_<(sizeof(I) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<I>::value>()); detail::check_shift_range(b, std::integral_constant<bool, (sizeof(I) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<I>::value>());
eval_left_shift(result.backend(), b); eval_left_shift(result.backend(), b);
return result; return result;
} }
@@ -302,7 +302,7 @@ namespace boost {
{ {
number<B, et_off> result(a); number<B, et_off> result(a);
using default_ops::eval_right_shift; using default_ops::eval_right_shift;
detail::check_shift_range(b, mpl::bool_<(sizeof(I) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<I>::value>()); detail::check_shift_range(b, std::integral_constant<bool, (sizeof(I) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<I>::value>());
eval_right_shift(result.backend(), b); eval_right_shift(result.backend(), b);
return result; return result;
} }
@@ -156,27 +156,27 @@ template <class Backend, expression_template_option ExpressionTemplates = expres
class number; class number;
template <class T> template <class T>
struct is_number : public mpl::false_ struct is_number : public std::integral_constant<bool, false>
{}; {};
template <class Backend, expression_template_option ExpressionTemplates> template <class Backend, expression_template_option ExpressionTemplates>
struct is_number<number<Backend, ExpressionTemplates> > : public mpl::true_ struct is_number<number<Backend, ExpressionTemplates> > : public std::integral_constant<bool, true>
{}; {};
template <class T> template <class T>
struct is_et_number : public mpl::false_ struct is_et_number : public std::integral_constant<bool, false>
{}; {};
template <class Backend> template <class Backend>
struct is_et_number<number<Backend, et_on> > : public mpl::true_ struct is_et_number<number<Backend, et_on> > : public std::integral_constant<bool, true>
{}; {};
template <class T> template <class T>
struct is_no_et_number : public mpl::false_ struct is_no_et_number : public std::integral_constant<bool, false>
{}; {};
template <class Backend> template <class Backend>
struct is_no_et_number<number<Backend, et_off> > : public mpl::true_ struct is_no_et_number<number<Backend, et_off> > : public std::integral_constant<bool, true>
{}; {};
namespace detail { namespace detail {
@@ -188,16 +188,16 @@ struct expression;
} // namespace detail } // namespace detail
template <class T> template <class T>
struct is_number_expression : public mpl::false_ struct is_number_expression : public std::integral_constant<bool, false>
{}; {};
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
struct is_number_expression<detail::expression<tag, Arg1, Arg2, Arg3, Arg4> > : public mpl::true_ struct is_number_expression<detail::expression<tag, Arg1, Arg2, Arg3, Arg4> > : public std::integral_constant<bool, true>
{}; {};
template <class T, class Num> template <class T, class Num>
struct is_compatible_arithmetic_type struct is_compatible_arithmetic_type
: public mpl::bool_< : public std::integral_constant<bool,
std::is_convertible<T, Num>::value && !std::is_same<T, Num>::value && !is_number_expression<T>::value> std::is_convertible<T, Num>::value && !std::is_same<T, Num>::value && !is_number_expression<T>::value>
{}; {};
@@ -257,10 +257,32 @@ template <int b>
struct has_enough_bits struct has_enough_bits
{ {
template <class T> template <class T>
struct type : public mpl::bool_<bits_of<T>::value >= b> struct type : public std::integral_constant<bool, bits_of<T>::value >= b>
{}; {};
}; };
template <class Tuple, int i, int digits, bool = (i == std::tuple_size<Tuple>::value)>
struct find_index_of_large_enough_type
{
static constexpr int value = bits_of<typename std::tuple_element<i, Tuple>::type>::value >= digits ? i : find_index_of_large_enough_type<Tuple, i + 1, digits>::value;
};
template <class Tuple, int i, int digits>
struct find_index_of_large_enough_type<Tuple, i, digits, true>
{
static constexpr int value = INT_MAX;
};
template <int index, class Tuple, class Fallback, bool = (std::tuple_size<Tuple>::value <= index)>
struct dereference_tuple
{
typedef typename std::tuple_element<index, Tuple>::type type;
};
template <int index, class Tuple, class Fallback>
struct dereference_tuple<index, Tuple, Fallback, true>
{
typedef Fallback type;
};
template <class Val, class Backend, class Tag> template <class Val, class Backend, class Tag>
struct canonical_imp struct canonical_imp
{ {
@@ -278,48 +300,36 @@ struct canonical_imp<number<B, et_off>, Backend, Tag>
}; };
#ifdef __SUNPRO_CC #ifdef __SUNPRO_CC
template <class B, class Backend> template <class B, class Backend>
struct canonical_imp<number<B, et_on>, Backend, mpl::int_<3> > struct canonical_imp<number<B, et_on>, Backend, std::integral_constant<int, 3> >
{ {
typedef B type; typedef B type;
}; };
template <class B, class Backend> template <class B, class Backend>
struct canonical_imp<number<B, et_off>, Backend, mpl::int_<3> > struct canonical_imp<number<B, et_off>, Backend, std::integral_constant<int, 3> >
{ {
typedef B type; typedef B type;
}; };
#endif #endif
template <class Val, class Backend> template <class Val, class Backend>
struct canonical_imp<Val, Backend, mpl::int_<0> > struct canonical_imp<Val, Backend, std::integral_constant<int, 0> >
{ {
typedef typename has_enough_bits<bits_of<Val>::value>::template type<mpl::_> pred_type; static constexpr int index = find_index_of_large_enough_type<typename Backend::signed_types, 0, bits_of<Val>::value>::value;
typedef typename mpl::find_if< typedef typename dereference_tuple<index, typename Backend::signed_types, Val>::type type;
typename Backend::signed_types,
pred_type>::type iter_type;
typedef typename mpl::end<typename Backend::signed_types>::type end_type;
typedef typename mpl::eval_if_c<std::is_same<iter_type, end_type>::value, mpl::identity<Val>, mpl::deref<iter_type> >::type type;
}; };
template <class Val, class Backend> template <class Val, class Backend>
struct canonical_imp<Val, Backend, mpl::int_<1> > struct canonical_imp<Val, Backend, std::integral_constant<int, 1> >
{ {
typedef typename has_enough_bits<bits_of<Val>::value>::template type<mpl::_> pred_type; static constexpr int index = find_index_of_large_enough_type<typename Backend::unsigned_types, 0, bits_of<Val>::value>::value;
typedef typename mpl::find_if< typedef typename dereference_tuple<index, typename Backend::unsigned_types, Val>::type type;
typename Backend::unsigned_types,
pred_type>::type iter_type;
typedef typename mpl::end<typename Backend::unsigned_types>::type end_type;
typedef typename mpl::eval_if_c<std::is_same<iter_type, end_type>::value, mpl::identity<Val>, mpl::deref<iter_type> >::type type;
}; };
template <class Val, class Backend> template <class Val, class Backend>
struct canonical_imp<Val, Backend, mpl::int_<2> > struct canonical_imp<Val, Backend, std::integral_constant<int, 2> >
{ {
typedef typename has_enough_bits<bits_of<Val>::value>::template type<mpl::_> pred_type; static constexpr int index = find_index_of_large_enough_type<typename Backend::float_types, 0, bits_of<Val>::value>::value;
typedef typename mpl::find_if< typedef typename dereference_tuple<index, typename Backend::float_types, Val>::type type;
typename Backend::float_types,
pred_type>::type iter_type;
typedef typename mpl::end<typename Backend::float_types>::type end_type;
typedef typename mpl::eval_if_c<std::is_same<iter_type, end_type>::value, mpl::identity<Val>, mpl::deref<iter_type> >::type type;
}; };
template <class Val, class Backend> template <class Val, class Backend>
struct canonical_imp<Val, Backend, mpl::int_<3> > struct canonical_imp<Val, Backend, std::integral_constant<int, 3> >
{ {
typedef const char* type; typedef const char* type;
}; };
@@ -329,17 +339,17 @@ struct canonical
{ {
typedef typename std::conditional< typedef typename std::conditional<
boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value, boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value,
mpl::int_<0>, std::integral_constant<int, 0>,
typename std::conditional< typename std::conditional<
boost::multiprecision::detail::is_unsigned<Val>::value, boost::multiprecision::detail::is_unsigned<Val>::value,
mpl::int_<1>, std::integral_constant<int, 1>,
typename std::conditional< typename std::conditional<
std::is_floating_point<Val>::value, std::is_floating_point<Val>::value,
mpl::int_<2>, std::integral_constant<int, 2>,
typename std::conditional< typename std::conditional<
(std::is_convertible<Val, const char*>::value || std::is_same<Val, std::string>::value), (std::is_convertible<Val, const char*>::value || std::is_same<Val, std::string>::value),
mpl::int_<3>, std::integral_constant<int, 3>,
mpl::int_<4> >::type>::type>::type>::type tag_type; std::integral_constant<int, 4> >::type>::type>::type>::type tag_type;
typedef typename canonical_imp<Val, Backend, tag_type>::type type; typedef typename canonical_imp<Val, Backend, tag_type>::type type;
}; };
@@ -499,7 +509,7 @@ struct expression_storage<expression<tag, A1, A2, A3, A4> >
template <class tag, class Arg1> template <class tag, class Arg1>
struct expression<tag, Arg1, void, void, void> struct expression<tag, Arg1, void, void, void>
{ {
typedef mpl::int_<1> arity; typedef std::integral_constant<int, 1> arity;
typedef typename arg_type<Arg1>::type left_type; typedef typename arg_type<Arg1>::type left_type;
typedef typename left_type::result_type left_result_type; typedef typename left_type::result_type left_result_type;
typedef typename left_type::result_type result_type; typedef typename left_type::result_type result_type;
@@ -653,7 +663,7 @@ struct expression<tag, Arg1, void, void, void>
template <class Arg1> template <class Arg1>
struct expression<terminal, Arg1, void, void, void> struct expression<terminal, Arg1, void, void, void>
{ {
typedef mpl::int_<0> arity; typedef std::integral_constant<int, 0> arity;
typedef Arg1 result_type; typedef Arg1 result_type;
typedef terminal tag_type; typedef terminal tag_type;
@@ -804,7 +814,7 @@ struct expression<terminal, Arg1, void, void, void>
template <class tag, class Arg1, class Arg2> template <class tag, class Arg1, class Arg2>
struct expression<tag, Arg1, Arg2, void, void> struct expression<tag, Arg1, Arg2, void, void>
{ {
typedef mpl::int_<2> arity; typedef std::integral_constant<int, 2> arity;
typedef typename arg_type<Arg1>::type left_type; typedef typename arg_type<Arg1>::type left_type;
typedef typename arg_type<Arg2>::type right_type; typedef typename arg_type<Arg2>::type right_type;
typedef typename left_type::result_type left_result_type; typedef typename left_type::result_type left_result_type;
@@ -964,7 +974,7 @@ struct expression<tag, Arg1, Arg2, void, void>
template <class tag, class Arg1, class Arg2, class Arg3> template <class tag, class Arg1, class Arg2, class Arg3>
struct expression<tag, Arg1, Arg2, Arg3, void> struct expression<tag, Arg1, Arg2, Arg3, void>
{ {
typedef mpl::int_<3> arity; typedef std::integral_constant<int, 3> arity;
typedef typename arg_type<Arg1>::type left_type; typedef typename arg_type<Arg1>::type left_type;
typedef typename arg_type<Arg2>::type middle_type; typedef typename arg_type<Arg2>::type middle_type;
typedef typename arg_type<Arg3>::type right_type; typedef typename arg_type<Arg3>::type right_type;
@@ -1132,7 +1142,7 @@ struct expression<tag, Arg1, Arg2, Arg3, void>
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
struct expression struct expression
{ {
typedef mpl::int_<4> arity; typedef std::integral_constant<int, 4> arity;
typedef typename arg_type<Arg1>::type left_type; typedef typename arg_type<Arg1>::type left_type;
typedef typename arg_type<Arg2>::type left_middle_type; typedef typename arg_type<Arg2>::type left_middle_type;
typedef typename arg_type<Arg3>::type right_middle_type; typedef typename arg_type<Arg3>::type right_middle_type;
@@ -1462,7 +1472,7 @@ void format_float_string(S& str, std::intmax_t my_exp, std::intmax_t digits, std
} }
template <class V> template <class V>
BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const mpl::true_&, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&)
{ {
if (val > (std::numeric_limits<std::size_t>::max)()) if (val > (std::numeric_limits<std::size_t>::max)())
BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max().")); BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max()."));
@@ -1470,19 +1480,19 @@ BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const mpl::true_&, const
BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a negative value.")); BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a negative value."));
} }
template <class V> template <class V>
BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const mpl::false_&, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&)
{ {
if (val < 0) if (val < 0)
BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a negative value.")); BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a negative value."));
} }
template <class V> template <class V>
BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const mpl::true_&, const mpl::false_&) BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V val, const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&)
{ {
if (val > (std::numeric_limits<std::size_t>::max)()) if (val > (std::numeric_limits<std::size_t>::max)())
BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max().")); BOOST_THROW_EXCEPTION(std::out_of_range("Can not shift by a value greater than std::numeric_limits<std::size_t>::max()."));
} }
template <class V> template <class V>
BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V, const mpl::false_&, const mpl::false_&) BOOST_NOEXCEPT {} BOOST_MP_CXX14_CONSTEXPR void check_shift_range(V, const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&) BOOST_NOEXCEPT {}
template <class T> template <class T>
BOOST_MP_CXX14_CONSTEXPR const T& evaluate_if_expression(const T& val) { return val; } BOOST_MP_CXX14_CONSTEXPR const T& evaluate_if_expression(const T& val) { return val; }
@@ -1505,10 +1515,10 @@ enum number_category_type
}; };
template <class Num, bool, bool> template <class Num, bool, bool>
struct number_category_base : public mpl::int_<number_kind_unknown> struct number_category_base : public std::integral_constant<int, number_kind_unknown>
{}; {};
template <class Num> template <class Num>
struct number_category_base<Num, true, false> : public mpl::int_<std::numeric_limits<Num>::is_integer ? number_kind_integer : (std::numeric_limits<Num>::max_exponent ? number_kind_floating_point : number_kind_unknown)> struct number_category_base<Num, true, false> : public std::integral_constant<int, std::numeric_limits<Num>::is_integer ? number_kind_integer : (std::numeric_limits<Num>::max_exponent ? number_kind_floating_point : number_kind_unknown)>
{}; {};
template <class Num> template <class Num>
struct number_category : public number_category_base<Num, std::is_class<Num>::value || boost::multiprecision::detail::is_arithmetic<Num>::value, std::is_abstract<Num>::value> struct number_category : public number_category_base<Num, std::is_class<Num>::value || boost::multiprecision::detail::is_arithmetic<Num>::value, std::is_abstract<Num>::value>
@@ -1524,15 +1534,15 @@ struct number_category<detail::expression<tag, A1, A2, A3, A4> > : public number
// //
#ifdef BOOST_HAS_INT128 #ifdef BOOST_HAS_INT128
template <> template <>
struct number_category<boost::int128_type> : public mpl::int_<number_kind_integer> struct number_category<boost::int128_type> : public std::integral_constant<int, number_kind_integer>
{}; {};
template <> template <>
struct number_category<boost::uint128_type> : public mpl::int_<number_kind_integer> struct number_category<boost::uint128_type> : public std::integral_constant<int, number_kind_integer>
{}; {};
#endif #endif
#ifdef BOOST_HAS_FLOAT128 #ifdef BOOST_HAS_FLOAT128
template <> template <>
struct number_category<__float128> : public mpl::int_<number_kind_floating_point> struct number_category<__float128> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
#endif #endif
@@ -1556,16 +1566,16 @@ template <class T>
struct complex_result_from_scalar; // individual backends must specialize this trait. struct complex_result_from_scalar; // individual backends must specialize this trait.
template <class T> template <class T>
struct is_unsigned_number : public mpl::false_ struct is_unsigned_number : public std::integral_constant<bool, false>
{}; {};
template <class Backend, expression_template_option ExpressionTemplates> template <class Backend, expression_template_option ExpressionTemplates>
struct is_unsigned_number<number<Backend, ExpressionTemplates> > : public is_unsigned_number<Backend> struct is_unsigned_number<number<Backend, ExpressionTemplates> > : public is_unsigned_number<Backend>
{}; {};
template <class T> template <class T>
struct is_signed_number : public mpl::bool_<!is_unsigned_number<T>::value> struct is_signed_number : public std::integral_constant<bool, !is_unsigned_number<T>::value>
{}; {};
template <class T> template <class T>
struct is_interval_number : public mpl::false_ struct is_interval_number : public std::integral_constant<bool, false>
{}; {};
template <class Backend, expression_template_option ExpressionTemplates> template <class Backend, expression_template_option ExpressionTemplates>
struct is_interval_number<number<Backend, ExpressionTemplates> > : public is_interval_number<Backend> struct is_interval_number<number<Backend, ExpressionTemplates> > : public is_interval_number<Backend>
@@ -1614,7 +1624,7 @@ namespace boost { namespace math {
} }
template <class B, boost::multiprecision::expression_template_option ET> template <class B, boost::multiprecision::expression_template_option ET>
struct is_complex_type<boost::multiprecision::number<B, ET> > : public boost::mpl::bool_<boost::multiprecision::number_category<B>::value == boost::multiprecision::number_kind_complex> {}; struct is_complex_type<boost::multiprecision::number<B, ET> > : public std::integral_constant<bool, boost::multiprecision::number_category<B>::value == boost::multiprecision::number_kind_complex> {};
} // namespace tools } // namespace tools
@@ -27,13 +27,13 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq(const B& a, const B& b)
return a.compare(b) == 0; return a.compare(b) == 0;
} }
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq_imp(const T& a, const U& b, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq_imp(const T& a, const U& b, const std::integral_constant<bool, true>&)
{ {
typename boost::multiprecision::detail::number_from_backend<T, U>::type t(b); typename boost::multiprecision::detail::number_from_backend<T, U>::type t(b);
return eval_eq(a, t.backend()); return eval_eq(a, t.backend());
} }
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq_imp(const T& a, const U& b, const mpl::false_&) inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq_imp(const T& a, const U& b, const std::integral_constant<bool, false>&)
{ {
typename boost::multiprecision::detail::number_from_backend<U, T>::type t(a); typename boost::multiprecision::detail::number_from_backend<U, T>::type t(a);
return eval_eq(t.backend(), b); return eval_eq(t.backend(), b);
@@ -41,7 +41,7 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq_imp(const T& a, const U& b, const m
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq(const T& a, const U& b) inline BOOST_MP_CXX14_CONSTEXPR bool eval_eq(const T& a, const U& b)
{ {
typedef mpl::bool_<boost::multiprecision::detail::is_first_backend<T, U>::value> tag_type; typedef std::integral_constant<bool, boost::multiprecision::detail::is_first_backend<T, U>::value> tag_type;
return eval_eq_imp(a, b, tag_type()); return eval_eq_imp(a, b, tag_type());
} }
@@ -51,13 +51,13 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt(const B& a, const B& b)
return a.compare(b) < 0; return a.compare(b) < 0;
} }
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt_imp(const T& a, const U& b, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt_imp(const T& a, const U& b, const std::integral_constant<bool, true>&)
{ {
typename boost::multiprecision::detail::number_from_backend<T, U>::type t(b); typename boost::multiprecision::detail::number_from_backend<T, U>::type t(b);
return eval_lt(a, t.backend()); return eval_lt(a, t.backend());
} }
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt_imp(const T& a, const U& b, const mpl::false_&) inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt_imp(const T& a, const U& b, const std::integral_constant<bool, false>&)
{ {
typename boost::multiprecision::detail::number_from_backend<U, T>::type t(a); typename boost::multiprecision::detail::number_from_backend<U, T>::type t(a);
return eval_lt(t.backend(), b); return eval_lt(t.backend(), b);
@@ -65,7 +65,7 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt_imp(const T& a, const U& b, const m
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt(const T& a, const U& b) inline BOOST_MP_CXX14_CONSTEXPR bool eval_lt(const T& a, const U& b)
{ {
typedef mpl::bool_<boost::multiprecision::detail::is_first_backend<T, U>::value> tag_type; typedef std::integral_constant<bool, boost::multiprecision::detail::is_first_backend<T, U>::value> tag_type;
return eval_lt_imp(a, b, tag_type()); return eval_lt_imp(a, b, tag_type());
} }
@@ -75,13 +75,13 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt(const B& a, const B& b)
return a.compare(b) > 0; return a.compare(b) > 0;
} }
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt_imp(const T& a, const U& b, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt_imp(const T& a, const U& b, const std::integral_constant<bool, true>&)
{ {
typename boost::multiprecision::detail::number_from_backend<T, U>::type t(b); typename boost::multiprecision::detail::number_from_backend<T, U>::type t(b);
return eval_gt(a, t.backend()); return eval_gt(a, t.backend());
} }
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt_imp(const T& a, const U& b, const mpl::false_&) inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt_imp(const T& a, const U& b, const std::integral_constant<bool, false>&)
{ {
typename boost::multiprecision::detail::number_from_backend<U, T>::type t(a); typename boost::multiprecision::detail::number_from_backend<U, T>::type t(a);
return eval_gt(t.backend(), b); return eval_gt(t.backend(), b);
@@ -89,7 +89,7 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt_imp(const T& a, const U& b, const m
template <class T, class U> template <class T, class U>
inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt(const T& a, const U& b) inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt(const T& a, const U& b)
{ {
typedef mpl::bool_<boost::multiprecision::detail::is_first_backend<T, U>::value> tag_type; typedef std::integral_constant<bool, boost::multiprecision::detail::is_first_backend<T, U>::value> tag_type;
return eval_gt_imp(a, b, tag_type()); return eval_gt_imp(a, b, tag_type());
} }
@@ -98,7 +98,7 @@ inline BOOST_MP_CXX14_CONSTEXPR bool eval_gt(const T& a, const U& b)
namespace detail { namespace detail {
template <class Num, class Val> template <class Num, class Val>
struct is_valid_mixed_compare : public mpl::false_ struct is_valid_mixed_compare : public std::integral_constant<bool, false>
{}; {};
template <class B, expression_template_option ET, class Val> template <class B, expression_template_option ET, class Val>
@@ -106,7 +106,7 @@ struct is_valid_mixed_compare<number<B, ET>, Val> : public std::is_convertible<V
{}; {};
template <class B, expression_template_option ET> template <class B, expression_template_option ET>
struct is_valid_mixed_compare<number<B, ET>, number<B, ET> > : public mpl::false_ struct is_valid_mixed_compare<number<B, ET>, number<B, ET> > : public std::integral_constant<bool, false>
{}; {};
template <class B, expression_template_option ET, class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class B, expression_template_option ET, class tag, class Arg1, class Arg2, class Arg3, class Arg4>
@@ -13,12 +13,12 @@
namespace boost { namespace multiprecision { namespace detail { namespace boost { namespace multiprecision { namespace detail {
template <class B, boost::multiprecision::expression_template_option ET> template <class B, boost::multiprecision::expression_template_option ET>
inline constexpr unsigned current_precision_of_last_chance_imp(const boost::multiprecision::number<B, ET>&, const mpl::false_&) inline constexpr unsigned current_precision_of_last_chance_imp(const boost::multiprecision::number<B, ET>&, const std::integral_constant<bool, false>&)
{ {
return std::numeric_limits<boost::multiprecision::number<B, ET> >::digits10; return std::numeric_limits<boost::multiprecision::number<B, ET> >::digits10;
} }
template <class B, boost::multiprecision::expression_template_option ET> template <class B, boost::multiprecision::expression_template_option ET>
inline BOOST_MP_CXX14_CONSTEXPR unsigned current_precision_of_last_chance_imp(const boost::multiprecision::number<B, ET>& val, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR unsigned current_precision_of_last_chance_imp(const boost::multiprecision::number<B, ET>& val, const std::integral_constant<bool, true>&)
{ {
// //
// We have an arbitrary precision integer, take it's "precision" as the // We have an arbitrary precision integer, take it's "precision" as the
@@ -38,7 +38,7 @@ template <class B, boost::multiprecision::expression_template_option ET>
inline constexpr unsigned current_precision_of_imp(const boost::multiprecision::number<B, ET>& val, const std::integral_constant<bool, false>&) inline constexpr unsigned current_precision_of_imp(const boost::multiprecision::number<B, ET>& val, const std::integral_constant<bool, false>&)
{ {
return current_precision_of_last_chance_imp(val, return current_precision_of_last_chance_imp(val,
mpl::bool_ < std::integral_constant<bool,
std::numeric_limits<boost::multiprecision::number<B, ET> >::is_specialized && std::numeric_limits<boost::multiprecision::number<B, ET> >::is_specialized &&
std::numeric_limits<boost::multiprecision::number<B, ET> >::is_integer && std::numeric_limits<boost::multiprecision::number<B, ET> >::is_exact && !std::numeric_limits<boost::multiprecision::number<B, ET> >::is_modulo > ()); std::numeric_limits<boost::multiprecision::number<B, ET> >::is_integer && std::numeric_limits<boost::multiprecision::number<B, ET> >::is_exact && !std::numeric_limits<boost::multiprecision::number<B, ET> >::is_modulo > ());
} }
@@ -158,10 +158,10 @@ struct scoped_default_precision<R, true>
}; };
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T*, const mpl::false_&) {} inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T*, const std::integral_constant<bool, false>&) {}
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T* obj, const mpl::true_&) inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T* obj, const std::integral_constant<bool, true>&)
{ {
if (obj->precision() != T::default_precision()) if (obj->precision() != T::default_precision())
{ {
@@ -172,7 +172,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T* obj, const mpl::
template <class T> template <class T>
inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T* obj) inline BOOST_MP_CXX14_CONSTEXPR void maybe_promote_precision(T* obj)
{ {
maybe_promote_precision(obj, mpl::bool_<boost::multiprecision::detail::is_variable_precision<T>::value>()); maybe_promote_precision(obj, std::integral_constant<bool, boost::multiprecision::detail::is_variable_precision<T>::value>());
} }
#ifndef BOOST_NO_CXX17_IF_CONSTEXPR #ifndef BOOST_NO_CXX17_IF_CONSTEXPR
+3 -3
View File
@@ -47,18 +47,18 @@ struct NumTraits<boost::multiprecision::number<Backend, ExpressionTemplates> >
{ {
return (std::numeric_limits<Real>::min)(); return (std::numeric_limits<Real>::min)();
} }
static int digits10_imp(const boost::mpl::true_&) static int digits10_imp(const std::integral_constant<bool, true>&)
{ {
return std::numeric_limits<Real>::digits10; return std::numeric_limits<Real>::digits10;
} }
template <bool B> template <bool B>
static int digits10_imp(const boost::mpl::bool_<B>&) static int digits10_imp(const std::integral_constant<bool, B>&)
{ {
return Real::default_precision(); return Real::default_precision();
} }
static int digits10() static int digits10()
{ {
return digits10_imp(boost::mpl::bool_ < std::numeric_limits<Real>::digits10 && (std::numeric_limits<Real>::digits10 != INT_MAX) ? true : false > ()); return digits10_imp(std::integral_constant<bool, std::numeric_limits<Real>::digits10 && (std::numeric_limits<Real>::digits10 != INT_MAX) ? true : false > ());
} }
}; };
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
+11 -12
View File
@@ -7,7 +7,6 @@
#define BOOST_MP_FLOAT128_HPP #define BOOST_MP_FLOAT128_HPP
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/scoped_array.hpp>
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <boost/multiprecision/number.hpp> #include <boost/multiprecision/number.hpp>
@@ -133,11 +132,11 @@ struct float128_backend;
using backends::float128_backend; using backends::float128_backend;
template <> template <>
struct number_category<backends::float128_backend> : public mpl::int_<number_kind_floating_point> struct number_category<backends::float128_backend> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
#if defined(BOOST_MP_USE_QUAD) #if defined(BOOST_MP_USE_QUAD)
template <> template <>
struct number_category<float128_type> : public mpl::int_<number_kind_floating_point> struct number_category<float128_type> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
#endif #endif
@@ -162,11 +161,11 @@ namespace backends {
struct float128_backend struct float128_backend
{ {
typedef mpl::list<signed char, short, int, long, boost::long_long_type> signed_types; typedef std::tuple<signed char, short, int, long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned char, unsigned short, typedef std::tuple<unsigned char, unsigned short,
unsigned int, unsigned long, boost::ulong_long_type> unsigned int, unsigned long, boost::ulong_long_type>
unsigned_types; unsigned_types;
typedef mpl::list<float, double, long double> float_types; typedef std::tuple<float, double, long double> float_types;
typedef int exponent_type; typedef int exponent_type;
private: private:
@@ -259,7 +258,7 @@ struct float128_backend
if ((v < 0) || (v >= 127)) if ((v < 0) || (v >= 127))
{ {
int v_max = v; int v_max = v;
boost::scoped_array<char> buf2; std::unique_ptr<char[]> buf2;
buf2.reset(new char[v + 3]); buf2.reset(new char[v + 3]);
v = quadmath_snprintf(&buf2[0], v_max + 3, format.c_str(), digits, m_value); v = quadmath_snprintf(&buf2[0], v_max + 3, format.c_str(), digits, m_value);
if (v >= v_max + 3) if (v >= v_max + 3)
@@ -741,7 +740,7 @@ namespace serialization {
namespace float128_detail { namespace float128_detail {
template <class Archive> template <class Archive>
void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const mpl::false_&, const mpl::false_&) void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const std::integral_constant<bool, false>&, const std::integral_constant<bool, false>&)
{ {
// saving // saving
// non-binary // non-binary
@@ -749,7 +748,7 @@ void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend
ar& boost::make_nvp("value", s); ar& boost::make_nvp("value", s);
} }
template <class Archive> template <class Archive>
void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const mpl::true_&, const mpl::false_&) void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const std::integral_constant<bool, true>&, const std::integral_constant<bool, false>&)
{ {
// loading // loading
// non-binary // non-binary
@@ -759,14 +758,14 @@ void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend
} }
template <class Archive> template <class Archive>
void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const mpl::false_&, const mpl::true_&) void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const std::integral_constant<bool, false>&, const std::integral_constant<bool, true>&)
{ {
// saving // saving
// binary // binary
ar.save_binary(&val, sizeof(val)); ar.save_binary(&val, sizeof(val));
} }
template <class Archive> template <class Archive>
void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const mpl::true_&, const mpl::true_&) void do_serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, const std::integral_constant<bool, true>&, const std::integral_constant<bool, true>&)
{ {
// loading // loading
// binary // binary
@@ -779,7 +778,7 @@ template <class Archive>
void serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, unsigned int /*version*/) void serialize(Archive& ar, boost::multiprecision::backends::float128_backend& val, unsigned int /*version*/)
{ {
typedef typename Archive::is_loading load_tag; typedef typename Archive::is_loading load_tag;
typedef typename mpl::bool_<std::is_same<Archive, boost::archive::binary_oarchive>::value || std::is_same<Archive, boost::archive::binary_iarchive>::value> binary_tag; typedef typename std::integral_constant<bool, std::is_same<Archive, boost::archive::binary_oarchive>::value || std::is_same<Archive, boost::archive::binary_iarchive>::value> binary_tag;
float128_detail::do_serialize(ar, val, load_tag(), binary_tag()); float128_detail::do_serialize(ar, val, load_tag(), binary_tag());
} }
+21 -21
View File
@@ -63,13 +63,13 @@ struct gmp_rational;
} // namespace backends } // namespace backends
template <> template <>
struct number_category<backends::gmp_int> : public mpl::int_<number_kind_integer> struct number_category<backends::gmp_int> : public std::integral_constant<int, number_kind_integer>
{}; {};
template <> template <>
struct number_category<backends::gmp_rational> : public mpl::int_<number_kind_rational> struct number_category<backends::gmp_rational> : public std::integral_constant<int, number_kind_rational>
{}; {};
template <unsigned digits10> template <unsigned digits10>
struct number_category<backends::gmp_float<digits10> > : public mpl::int_<number_kind_floating_point> struct number_category<backends::gmp_float<digits10> > : public std::integral_constant<int, number_kind_floating_point>
{}; {};
namespace backends { namespace backends {
@@ -84,13 +84,13 @@ template <unsigned digits10>
struct gmp_float_imp struct gmp_float_imp
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
typedef long exponent_type; typedef long exponent_type;
gmp_float_imp() BOOST_NOEXCEPT gmp_float_imp() BOOST_NOEXCEPT
@@ -1111,13 +1111,13 @@ inline std::size_t hash_value(const gmp_float<Digits10>& val)
struct gmp_int struct gmp_int
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
gmp_int() gmp_int()
{ {
@@ -2017,13 +2017,13 @@ void eval_add(gmp_rational& t, const gmp_rational& o);
struct gmp_rational struct gmp_rational
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
gmp_rational() gmp_rational()
{ {
@@ -2586,13 +2586,13 @@ struct transcendental_reduction_type<boost::multiprecision::backends::gmp_float<
} // namespace detail } // namespace detail
template <> template <>
struct number_category<detail::canonical<mpz_t, gmp_int>::type> : public mpl::int_<number_kind_integer> struct number_category<detail::canonical<mpz_t, gmp_int>::type> : public std::integral_constant<int, number_kind_integer>
{}; {};
template <> template <>
struct number_category<detail::canonical<mpq_t, gmp_rational>::type> : public mpl::int_<number_kind_rational> struct number_category<detail::canonical<mpq_t, gmp_rational>::type> : public std::integral_constant<int, number_kind_rational>
{}; {};
template <> template <>
struct number_category<detail::canonical<mpf_t, gmp_float<0> >::type> : public mpl::int_<number_kind_floating_point> struct number_category<detail::canonical<mpf_t, gmp_float<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
namespace detail { namespace detail {
+7 -7
View File
@@ -33,7 +33,7 @@ struct mpc_complex_backend;
} // namespace backends } // namespace backends
template <unsigned digits10> template <unsigned digits10>
struct number_category<backends::mpc_complex_backend<digits10> > : public mpl::int_<number_kind_complex> struct number_category<backends::mpc_complex_backend<digits10> > : public std::integral_constant<int, number_kind_complex>
{}; {};
namespace backends { namespace backends {
@@ -62,13 +62,13 @@ template <unsigned digits10>
struct mpc_complex_imp struct mpc_complex_imp
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
typedef long exponent_type; typedef long exponent_type;
mpc_complex_imp() mpc_complex_imp()
@@ -1475,7 +1475,7 @@ struct is_variable_precision<backends::mpc_complex_backend<0> > : public std::in
} // namespace detail } // namespace detail
template <> template <>
struct number_category<detail::canonical<mpc_t, backends::mpc_complex_backend<0> >::type> : public mpl::int_<number_kind_floating_point> struct number_category<detail::canonical<mpc_t, backends::mpc_complex_backend<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
using boost::multiprecision::backends::mpc_complex_backend; using boost::multiprecision::backends::mpc_complex_backend;
+11 -11
View File
@@ -35,7 +35,7 @@ struct mpfi_float_backend;
} // namespace backends } // namespace backends
template <unsigned digits10> template <unsigned digits10>
struct number_category<backends::mpfi_float_backend<digits10> > : public mpl::int_<number_kind_floating_point> struct number_category<backends::mpfi_float_backend<digits10> > : public std::integral_constant<int, number_kind_floating_point>
{}; {};
struct interval_error : public std::runtime_error struct interval_error : public std::runtime_error
@@ -65,13 +65,13 @@ template <unsigned digits10>
struct mpfi_float_imp struct mpfi_float_imp
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
typedef long exponent_type; typedef long exponent_type;
mpfi_float_imp() mpfi_float_imp()
@@ -1082,7 +1082,7 @@ inline std::size_t hash_value(const mpfi_float_backend<Digits10>& val)
} }
template <class To, unsigned D> template <class To, unsigned D>
void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const mpl::int_<number_kind_integer>& to_type, const mpl::int_<number_kind_floating_point>& from_type) void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const std::integral_constant<int, number_kind_integer>& to_type, const std::integral_constant<int, number_kind_floating_point>& from_type)
{ {
using boost::multiprecision::detail::generic_interconvert; using boost::multiprecision::detail::generic_interconvert;
mpfr_float_backend<D> t; mpfr_float_backend<D> t;
@@ -1091,7 +1091,7 @@ void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const mpl::
} }
template <class To, unsigned D> template <class To, unsigned D>
void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const mpl::int_<number_kind_rational>& to_type, const mpl::int_<number_kind_floating_point>& from_type) void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const std::integral_constant<int, number_kind_rational>& to_type, const std::integral_constant<int, number_kind_floating_point>& from_type)
{ {
using boost::multiprecision::detail::generic_interconvert; using boost::multiprecision::detail::generic_interconvert;
mpfr_float_backend<D> t; mpfr_float_backend<D> t;
@@ -1100,7 +1100,7 @@ void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const mpl::
} }
template <class To, unsigned D> template <class To, unsigned D>
void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const mpl::int_<number_kind_floating_point>& to_type, const mpl::int_<number_kind_floating_point>& from_type) void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const std::integral_constant<int, number_kind_floating_point>& to_type, const std::integral_constant<int, number_kind_floating_point>& from_type)
{ {
using boost::multiprecision::detail::generic_interconvert; using boost::multiprecision::detail::generic_interconvert;
mpfr_float_backend<D> t; mpfr_float_backend<D> t;
@@ -1117,10 +1117,10 @@ struct is_variable_precision<backends::mpfi_float_backend<0> > : public std::int
} // namespace detail } // namespace detail
template <> template <>
struct number_category<detail::canonical<mpfi_t, backends::mpfi_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point> struct number_category<detail::canonical<mpfi_t, backends::mpfi_float_backend<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
template <unsigned Digits10> template <unsigned Digits10>
struct is_interval_number<backends::mpfi_float_backend<Digits10> > : public mpl::true_ struct is_interval_number<backends::mpfi_float_backend<Digits10> > : public std::integral_constant<bool, true>
{}; {};
using boost::multiprecision::backends::mpfi_float_backend; using boost::multiprecision::backends::mpfi_float_backend;
+13 -13
View File
@@ -43,7 +43,7 @@ struct mpfr_float_backend<0, allocate_stack>;
} // namespace backends } // namespace backends
template <unsigned digits10, mpfr_allocation_type AllocationType> template <unsigned digits10, mpfr_allocation_type AllocationType>
struct number_category<backends::mpfr_float_backend<digits10, AllocationType> > : public mpl::int_<number_kind_floating_point> struct number_category<backends::mpfr_float_backend<digits10, AllocationType> > : public std::integral_constant<int, number_kind_floating_point>
{}; {};
namespace backends { namespace backends {
@@ -91,13 +91,13 @@ template <unsigned digits10>
struct mpfr_float_imp<digits10, allocate_dynamic> struct mpfr_float_imp<digits10, allocate_dynamic>
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
typedef long exponent_type; typedef long exponent_type;
mpfr_float_imp() mpfr_float_imp()
@@ -413,13 +413,13 @@ template <unsigned digits10>
struct mpfr_float_imp<digits10, allocate_stack> struct mpfr_float_imp<digits10, allocate_stack>
{ {
#ifdef BOOST_HAS_LONG_LONG #ifdef BOOST_HAS_LONG_LONG
typedef mpl::list<long, boost::long_long_type> signed_types; typedef std::tuple<long, boost::long_long_type> signed_types;
typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types; typedef std::tuple<unsigned long, boost::ulong_long_type> unsigned_types;
#else #else
typedef mpl::list<long> signed_types; typedef std::tuple<long> signed_types;
typedef mpl::list<unsigned long> unsigned_types; typedef std::tuple<unsigned long> unsigned_types;
#endif #endif
typedef mpl::list<double, long double> float_types; typedef std::tuple<double, long double> float_types;
typedef long exponent_type; typedef long exponent_type;
static const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u); static const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u);
@@ -1611,11 +1611,11 @@ struct is_variable_precision<backends::mpfr_float_backend<0> > : public std::int
} // namespace detail } // namespace detail
template <> template <>
struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point> struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
{}; {};
template <unsigned D, boost::multiprecision::mpfr_allocation_type A1, boost::multiprecision::mpfr_allocation_type A2> template <unsigned D, boost::multiprecision::mpfr_allocation_type A1, boost::multiprecision::mpfr_allocation_type A2>
struct is_equivalent_number_type<backends::mpfr_float_backend<D, A1>, backends::mpfr_float_backend<D, A2> > : public mpl::true_ {}; struct is_equivalent_number_type<backends::mpfr_float_backend<D, A1>, backends::mpfr_float_backend<D, A2> > : public std::integral_constant<bool, true> {};
using boost::multiprecision::backends::mpfr_float_backend; using boost::multiprecision::backends::mpfr_float_backend;
+21 -25
View File
@@ -8,10 +8,6 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <cstdint> #include <cstdint>
#include <boost/mpl/max.hpp>
#include <boost/mpl/plus.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/find_if.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
#include <boost/multiprecision/detail/precision.hpp> #include <boost/multiprecision/detail/precision.hpp>
@@ -186,7 +182,7 @@ class number
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_convertible<typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, self_type>::value, number&>::type operator=(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e) BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_convertible<typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type, self_type>::value, number&>::type operator=(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e)
{ {
typedef mpl::bool_<is_equivalent_number_type<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value> tag_type; typedef std::integral_constant<bool, is_equivalent_number_type<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value> tag_type;
detail::scoped_default_precision<number<Backend, ExpressionTemplates> > precision_guard(e); detail::scoped_default_precision<number<Backend, ExpressionTemplates> > precision_guard(e);
// //
// If the current precision of *this differs from that of expression e, then we // If the current precision of *this differs from that of expression e, then we
@@ -209,7 +205,7 @@ class number
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
BOOST_MP_CXX14_CONSTEXPR number& assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e) BOOST_MP_CXX14_CONSTEXPR number& assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e)
{ {
typedef mpl::bool_<is_equivalent_number_type<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value> tag_type; typedef std::integral_constant<bool, is_equivalent_number_type<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value> tag_type;
detail::scoped_default_precision<number<Backend, ExpressionTemplates> > precision_guard(e); detail::scoped_default_precision<number<Backend, ExpressionTemplates> > precision_guard(e);
// //
// If the current precision of *this differs from that of expression e, then we // If the current precision of *this differs from that of expression e, then we
@@ -622,7 +618,7 @@ class number
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<V>::value, number&>::type operator<<=(V val) BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<V>::value, number&>::type operator<<=(V val)
{ {
static_assert(number_category<Backend>::value == number_kind_integer, "The left-shift operation is only valid for integer types"); static_assert(number_category<Backend>::value == number_kind_integer, "The left-shift operation is only valid for integer types");
detail::check_shift_range(val, mpl::bool_<(sizeof(V) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<V>::value && boost::multiprecision::detail::is_integral<V>::value > ()); detail::check_shift_range(val, std::integral_constant<bool, (sizeof(V) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<V>::value && boost::multiprecision::detail::is_integral<V>::value > ());
eval_left_shift(m_backend, static_cast<std::size_t>(canonical_value(val))); eval_left_shift(m_backend, static_cast<std::size_t>(canonical_value(val)));
return *this; return *this;
} }
@@ -631,7 +627,7 @@ class number
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<V>::value, number&>::type operator>>=(V val) BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<boost::multiprecision::detail::is_integral<V>::value, number&>::type operator>>=(V val)
{ {
static_assert(number_category<Backend>::value == number_kind_integer, "The right-shift operation is only valid for integer types"); static_assert(number_category<Backend>::value == number_kind_integer, "The right-shift operation is only valid for integer types");
detail::check_shift_range(val, mpl::bool_<(sizeof(V) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<V>::value && boost::multiprecision::detail::is_integral<V>::value>()); detail::check_shift_range(val, std::integral_constant<bool, (sizeof(V) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<V>::value && boost::multiprecision::detail::is_integral<V>::value>());
eval_right_shift(m_backend, static_cast<std::size_t>(canonical_value(val))); eval_right_shift(m_backend, static_cast<std::size_t>(canonical_value(val)));
return *this; return *this;
} }
@@ -949,13 +945,13 @@ class number
private: private:
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
BOOST_MP_CXX14_CONSTEXPR void do_assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e, const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR void do_assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e, const std::integral_constant<bool, true>&)
{ {
do_assign(e, tag()); do_assign(e, tag());
} }
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_assignable<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value>::type BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_assignable<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value>::type
do_assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e, const mpl::false_&) do_assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e, const std::integral_constant<bool, false>&)
{ {
// The result of the expression isn't the same type as this - // The result of the expression isn't the same type as this -
// create a temporary result and assign it to *this: // create a temporary result and assign it to *this:
@@ -965,7 +961,7 @@ class number
} }
template <class tag, class Arg1, class Arg2, class Arg3, class Arg4> template <class tag, class Arg1, class Arg2, class Arg3, class Arg4>
BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!std::is_assignable<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value>::type BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<!std::is_assignable<number, typename detail::expression<tag, Arg1, Arg2, Arg3, Arg4>::result_type>::value>::type
do_assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e, const mpl::false_&) do_assign(const detail::expression<tag, Arg1, Arg2, Arg3, Arg4>& e, const std::integral_constant<bool, false>&)
{ {
// The result of the expression isn't the same type as this - // The result of the expression isn't the same type as this -
// create a temporary result and assign it to *this: // create a temporary result and assign it to *this:
@@ -1404,7 +1400,7 @@ class number
{ {
static_assert(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types"); static_assert(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types");
using default_ops::eval_right_shift; using default_ops::eval_right_shift;
detail::check_shift_range(val, mpl::bool_<(sizeof(Val) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>()); detail::check_shift_range(val, std::integral_constant<bool, (sizeof(Val) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>());
eval_right_shift(m_backend, canonical_value(e.value()), static_cast<std::size_t>(val)); eval_right_shift(m_backend, canonical_value(e.value()), static_cast<std::size_t>(val));
} }
@@ -1413,7 +1409,7 @@ class number
{ {
static_assert(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types"); static_assert(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types");
using default_ops::eval_left_shift; using default_ops::eval_left_shift;
detail::check_shift_range(val, mpl::bool_<(sizeof(Val) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>()); detail::check_shift_range(val, std::integral_constant<bool, (sizeof(Val) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>());
eval_left_shift(m_backend, canonical_value(e.value()), static_cast<std::size_t>(val)); eval_left_shift(m_backend, canonical_value(e.value()), static_cast<std::size_t>(val));
} }
@@ -1423,7 +1419,7 @@ class number
static_assert(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types"); static_assert(number_category<Backend>::value == number_kind_integer, "The right shift operation is only valid for integer types");
using default_ops::eval_right_shift; using default_ops::eval_right_shift;
self_type temp(e); self_type temp(e);
detail::check_shift_range(val, mpl::bool_<(sizeof(Val) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>()); detail::check_shift_range(val, std::integral_constant<bool, (sizeof(Val) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>());
eval_right_shift(m_backend, temp.backend(), static_cast<std::size_t>(val)); eval_right_shift(m_backend, temp.backend(), static_cast<std::size_t>(val));
} }
@@ -1433,17 +1429,17 @@ class number
static_assert(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types"); static_assert(number_category<Backend>::value == number_kind_integer, "The left shift operation is only valid for integer types");
using default_ops::eval_left_shift; using default_ops::eval_left_shift;
self_type temp(e); self_type temp(e);
detail::check_shift_range(val, mpl::bool_<(sizeof(Val) > sizeof(std::size_t))>(), mpl::bool_<boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>()); detail::check_shift_range(val, std::integral_constant<bool, (sizeof(Val) > sizeof(std::size_t))>(), std::integral_constant<bool, boost::multiprecision::detail::is_signed<Val>::value && boost::multiprecision::detail::is_integral<Val>::value>());
eval_left_shift(m_backend, temp.backend(), static_cast<std::size_t>(val)); eval_left_shift(m_backend, temp.backend(), static_cast<std::size_t>(val));
} }
template <class Exp> template <class Exp>
BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const mpl::int_<1>&) BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const std::integral_constant<int, 1>&)
{ {
e.left().value()(&m_backend); e.left().value()(&m_backend);
} }
template <class Exp> template <class Exp>
BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const mpl::int_<2>&) BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const std::integral_constant<int, 2>&)
{ {
typedef typename Exp::right_type right_type; typedef typename Exp::right_type right_type;
typedef typename right_type::tag_type tag_type; typedef typename right_type::tag_type tag_type;
@@ -1461,7 +1457,7 @@ class number
f(m_backend, t.backend()); f(m_backend, t.backend());
} }
template <class Exp> template <class Exp>
BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const mpl::int_<3>&) BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const std::integral_constant<int, 3>&)
{ {
typedef typename Exp::middle_type middle_type; typedef typename Exp::middle_type middle_type;
typedef typename middle_type::tag_type tag_type; typedef typename middle_type::tag_type tag_type;
@@ -1495,7 +1491,7 @@ class number
} }
template <class Exp> template <class Exp>
BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const mpl::int_<4>&) BOOST_MP_CXX14_CONSTEXPR void do_assign_function(const Exp& e, const std::integral_constant<int, 4>&)
{ {
typedef typename Exp::left_middle_type left_type; typedef typename Exp::left_middle_type left_type;
typedef typename left_type::tag_type left_tag_type; typedef typename left_type::tag_type left_tag_type;
@@ -1900,25 +1896,25 @@ class number
return contains_self(e, typename Exp::arity()); return contains_self(e, typename Exp::arity());
} }
template <class Exp> template <class Exp>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, mpl::int_<0> const&) const BOOST_NOEXCEPT BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, std::integral_constant<int, 0> const&) const BOOST_NOEXCEPT
{ {
return is_realy_self(e.value()); return is_realy_self(e.value());
} }
template <class Exp> template <class Exp>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, mpl::int_<1> const&) const BOOST_NOEXCEPT BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, std::integral_constant<int, 1> const&) const BOOST_NOEXCEPT
{ {
typedef typename Exp::left_type child_type; typedef typename Exp::left_type child_type;
return contains_self(e.left(), typename child_type::arity()); return contains_self(e.left(), typename child_type::arity());
} }
template <class Exp> template <class Exp>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, mpl::int_<2> const&) const BOOST_NOEXCEPT BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, std::integral_constant<int, 2> const&) const BOOST_NOEXCEPT
{ {
typedef typename Exp::left_type child0_type; typedef typename Exp::left_type child0_type;
typedef typename Exp::right_type child1_type; typedef typename Exp::right_type child1_type;
return contains_self(e.left(), typename child0_type::arity()) || contains_self(e.right(), typename child1_type::arity()); return contains_self(e.left(), typename child0_type::arity()) || contains_self(e.right(), typename child1_type::arity());
} }
template <class Exp> template <class Exp>
BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, mpl::int_<3> const&) const BOOST_NOEXCEPT BOOST_MP_FORCEINLINE BOOST_MP_CXX14_CONSTEXPR bool contains_self(const Exp& e, std::integral_constant<int, 3> const&) const BOOST_NOEXCEPT
{ {
typedef typename Exp::left_type child0_type; typedef typename Exp::left_type child0_type;
typedef typename Exp::middle_type child1_type; typedef typename Exp::middle_type child1_type;
@@ -1933,12 +1929,12 @@ class number
return is_self(e, typename Exp::arity()); return is_self(e, typename Exp::arity());
} }
template <class Exp> template <class Exp>
BOOST_MP_FORCEINLINE constexpr bool is_self(const Exp& e, mpl::int_<0> const&) const BOOST_NOEXCEPT BOOST_MP_FORCEINLINE constexpr bool is_self(const Exp& e, std::integral_constant<int, 0> const&) const BOOST_NOEXCEPT
{ {
return is_realy_self(e.value()); return is_realy_self(e.value());
} }
template <class Exp, int v> template <class Exp, int v>
BOOST_MP_FORCEINLINE constexpr bool is_self(const Exp&, mpl::int_<v> const&) const BOOST_NOEXCEPT BOOST_MP_FORCEINLINE constexpr bool is_self(const Exp&, std::integral_constant<int, v> const&) const BOOST_NOEXCEPT
{ {
return false; return false;
} }
@@ -181,7 +181,7 @@ struct rational_adaptor
const rational_type& data() const { return m_value; } const rational_type& data() const { return m_value; }
template <class Archive> template <class Archive>
void serialize(Archive& ar, const mpl::true_&) void serialize(Archive& ar, const std::integral_constant<bool, true>&)
{ {
// Saving // Saving
integer_type n(m_value.numerator()), d(m_value.denominator()); integer_type n(m_value.numerator()), d(m_value.denominator());
@@ -189,7 +189,7 @@ struct rational_adaptor
ar& boost::make_nvp("denominator", d); ar& boost::make_nvp("denominator", d);
} }
template <class Archive> template <class Archive>
void serialize(Archive& ar, const mpl::false_&) void serialize(Archive& ar, const std::integral_constant<bool, false>&)
{ {
// Loading // Loading
integer_type n, d; integer_type n, d;
@@ -201,7 +201,8 @@ struct rational_adaptor
void serialize(Archive& ar, const unsigned int /*version*/) void serialize(Archive& ar, const unsigned int /*version*/)
{ {
typedef typename Archive::is_saving tag; typedef typename Archive::is_saving tag;
serialize(ar, tag()); typedef std::integral_constant<bool, tag::value> saving_tag;
serialize(ar, saving_tag());
} }
private: private:
@@ -296,7 +297,7 @@ struct expression_template_default<backends::rational_adaptor<IntBackend> > : pu
{}; {};
template <class IntBackend> template <class IntBackend>
struct number_category<backends::rational_adaptor<IntBackend> > : public mpl::int_<number_kind_rational> struct number_category<backends::rational_adaptor<IntBackend> > : public std::integral_constant<int, number_kind_rational>
{}; {};
using boost::multiprecision::backends::rational_adaptor; using boost::multiprecision::backends::rational_adaptor;
+5 -6
View File
@@ -11,7 +11,6 @@
#include <boost/multiprecision/detail/integer_ops.hpp> #include <boost/multiprecision/detail/integer_ops.hpp>
#include <boost/math/special_functions/fpclassify.hpp> #include <boost/math/special_functions/fpclassify.hpp>
#include <cstdint> #include <cstdint>
#include <boost/scoped_array.hpp>
#include <boost/functional/hash_fwd.hpp> #include <boost/functional/hash_fwd.hpp>
#include <tommath.h> #include <tommath.h>
#include <cctype> #include <cctype>
@@ -43,9 +42,9 @@ void eval_add(tommath_int& t, const tommath_int& o);
struct tommath_int struct tommath_int
{ {
typedef mpl::list<std::int32_t, boost::long_long_type> signed_types; typedef std::tuple<std::int32_t, boost::long_long_type> signed_types;
typedef mpl::list<std::uint32_t, boost::ulong_long_type> unsigned_types; typedef std::tuple<std::uint32_t, boost::ulong_long_type> unsigned_types;
typedef mpl::list<long double> float_types; typedef std::tuple<long double> float_types;
tommath_int() tommath_int()
{ {
@@ -391,7 +390,7 @@ struct tommath_int
std::size_t s; std::size_t s;
detail::check_tommath_result(mp_radix_size(const_cast< ::mp_int*>(&m_data), base, &s)); detail::check_tommath_result(mp_radix_size(const_cast< ::mp_int*>(&m_data), base, &s));
#endif #endif
boost::scoped_array<char> a(new char[s + 1]); std::unique_ptr<char[]> a(new char[s + 1]);
#ifdef DIGIT_BIT #ifdef DIGIT_BIT
detail::check_tommath_result(mp_toradix_n(const_cast< ::mp_int*>(&m_data), a.get(), base, s + 1)); detail::check_tommath_result(mp_toradix_n(const_cast< ::mp_int*>(&m_data), a.get(), base, s + 1));
#else #else
@@ -779,7 +778,7 @@ inline std::size_t hash_value(const tommath_int& val)
using boost::multiprecision::backends::tommath_int; using boost::multiprecision::backends::tommath_int;
template <> template <>
struct number_category<tommath_int> : public mpl::int_<number_kind_integer> struct number_category<tommath_int> : public std::integral_constant<int, number_kind_integer>
{}; {};
typedef number<tommath_int> tom_int; typedef number<tommath_int> tom_int;
@@ -6,14 +6,37 @@
#ifndef BOOST_MP_IS_BACKEND_HPP #ifndef BOOST_MP_IS_BACKEND_HPP
#define BOOST_MP_IS_BACKEND_HPP #define BOOST_MP_IS_BACKEND_HPP
#include <boost/mpl/has_xxx.hpp>
#include <boost/multiprecision/detail/number_base.hpp> #include <boost/multiprecision/detail/number_base.hpp>
namespace boost { namespace multiprecision { namespace detail { namespace boost { namespace multiprecision { namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_DEF(signed_types) template <class T>
BOOST_MPL_HAS_XXX_TRAIT_DEF(unsigned_types) struct has_signed_types
BOOST_MPL_HAS_XXX_TRAIT_DEF(float_types) {
template <class U>
static double check(U*, typename U::signed_types* = 0);
static char check(...);
static T* get();
static constexpr bool value = sizeof(check(get())) == sizeof(double);
};
template <class T>
struct has_unsigned_types
{
template <class U>
static double check(U*, typename U::unsigned_types* = 0);
static char check(...);
static T* get();
static constexpr bool value = sizeof(check(get())) == sizeof(double);
};
template <class T>
struct has_float_types
{
template <class U>
static double check(U*, typename U::float_types* = 0);
static char check(...);
static T* get();
static constexpr bool value = sizeof(check(get())) == sizeof(double);
};
template <class T> template <class T>
struct is_backend struct is_backend
@@ -8,11 +8,19 @@
#include <iterator> #include <iterator>
#include <type_traits> #include <type_traits>
#include <boost/mpl/has_xxx.hpp>
namespace boost { namespace multiprecision { namespace detail { namespace boost { namespace multiprecision { namespace detail {
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_member_const_iterator, const_iterator, false) template <class T>
struct has_member_const_iterator
{
template <class U>
static double check(U*, typename U::const_iterator* = 0);
static char check(...);
static T* get();
static constexpr bool value = sizeof(check(get())) == sizeof(double);
};
template <class C, bool b> template <class C, bool b>
struct is_byte_container_imp struct is_byte_container_imp
@@ -8,7 +8,6 @@
#define BOOST_MP_RESTRICTED_CONVERSION_HPP #define BOOST_MP_RESTRICTED_CONVERSION_HPP
#include <boost/multiprecision/traits/explicit_conversion.hpp> #include <boost/multiprecision/traits/explicit_conversion.hpp>
#include <boost/mpl/if.hpp>
#include <boost/multiprecision/detail/number_base.hpp> #include <boost/multiprecision/detail/number_base.hpp>
namespace boost { namespace multiprecision { namespace detail { namespace boost { namespace multiprecision { namespace detail {
@@ -20,8 +19,8 @@ struct is_lossy_conversion
((number_category<From>::value == number_kind_floating_point) && (number_category<To>::value == number_kind_integer)) ((number_category<From>::value == number_kind_floating_point) && (number_category<To>::value == number_kind_integer))
/* || ((number_category<From>::value == number_kind_floating_point) && (number_category<To>::value == number_kind_rational))*/ /* || ((number_category<From>::value == number_kind_floating_point) && (number_category<To>::value == number_kind_rational))*/
|| ((number_category<From>::value == number_kind_rational) && (number_category<To>::value == number_kind_integer)) || ((number_category<From>::value == number_kind_fixed_point) && (number_category<To>::value == number_kind_integer)) || (number_category<From>::value == number_kind_unknown) || (number_category<To>::value == number_kind_unknown), || ((number_category<From>::value == number_kind_rational) && (number_category<To>::value == number_kind_integer)) || ((number_category<From>::value == number_kind_fixed_point) && (number_category<To>::value == number_kind_integer)) || (number_category<From>::value == number_kind_unknown) || (number_category<To>::value == number_kind_unknown),
mpl::true_, std::integral_constant<bool, true>,
mpl::false_>::type type; std::integral_constant<bool, false>>::type type;
static const bool value = type::value; static const bool value = type::value;
}; };
@@ -30,8 +29,8 @@ struct is_restricted_conversion
{ {
typedef typename std::conditional< typedef typename std::conditional<
((is_explicitly_convertible<From, To>::value && !std::is_convertible<From, To>::value) || is_lossy_conversion<From, To>::value), ((is_explicitly_convertible<From, To>::value && !std::is_convertible<From, To>::value) || is_lossy_conversion<From, To>::value),
mpl::true_, std::integral_constant<bool, true>,
mpl::false_>::type type; std::integral_constant<bool, false>>::type type;
static const bool value = type::value; static const bool value = type::value;
}; };
+7 -7
View File
@@ -28,9 +28,9 @@ namespace backends {
template <class Arithmetic> template <class Arithmetic>
struct arithmetic_backend struct arithmetic_backend
{ {
typedef mpl::list<short, int, long, long long> signed_types; typedef std::tuple<short, int, long, long long> signed_types;
typedef mpl::list<unsigned short, unsigned, unsigned long, unsigned long long> unsigned_types; typedef std::tuple<unsigned short, unsigned, unsigned long, unsigned long long> unsigned_types;
typedef mpl::list<float, double, long double> float_types; typedef std::tuple<float, double, long double> float_types;
typedef int exponent_type; typedef int exponent_type;
BOOST_MP_CXX14_CONSTEXPR arithmetic_backend() : m_value(0) {} BOOST_MP_CXX14_CONSTEXPR arithmetic_backend() : m_value(0) {}
@@ -83,17 +83,17 @@ struct arithmetic_backend
ss << std::setprecision(digits ? digits : std::numeric_limits<Arithmetic>::digits10 + 4) << m_value; ss << std::setprecision(digits ? digits : std::numeric_limits<Arithmetic>::digits10 + 4) << m_value;
return ss.str(); return ss.str();
} }
BOOST_MP_CXX14_CONSTEXPR void do_negate(const mpl::true_&) BOOST_MP_CXX14_CONSTEXPR void do_negate(const std::integral_constant<bool, true>&)
{ {
m_value = 1 + ~m_value; m_value = 1 + ~m_value;
} }
BOOST_MP_CXX14_CONSTEXPR void do_negate(const mpl::false_&) BOOST_MP_CXX14_CONSTEXPR void do_negate(const std::integral_constant<bool, false>&)
{ {
m_value = -m_value; m_value = -m_value;
} }
BOOST_MP_CXX14_CONSTEXPR void negate() BOOST_MP_CXX14_CONSTEXPR void negate()
{ {
do_negate(mpl::bool_<boost::multiprecision::detail::is_unsigned<Arithmetic>::value>()); do_negate(std::integral_constant<bool, boost::multiprecision::detail::is_unsigned<Arithmetic>::value>());
} }
BOOST_MP_CXX14_CONSTEXPR int compare(const arithmetic_backend& o) const BOOST_MP_CXX14_CONSTEXPR int compare(const arithmetic_backend& o) const
{ {
@@ -549,7 +549,7 @@ inline BOOST_MP_CXX14_CONSTEXPR std::size_t hash_value(const arithmetic_backend<
using boost::multiprecision::backends::arithmetic_backend; using boost::multiprecision::backends::arithmetic_backend;
template <class Arithmetic> template <class Arithmetic>
struct number_category<arithmetic_backend<Arithmetic> > : public mpl::int_<boost::multiprecision::detail::is_integral<Arithmetic>::value ? number_kind_integer : number_kind_floating_point> struct number_category<arithmetic_backend<Arithmetic> > : public std::integral_constant<int, boost::multiprecision::detail::is_integral<Arithmetic>::value ? number_kind_integer : number_kind_floating_point>
{}; {};
namespace detail { namespace detail {
+1 -1
View File
@@ -47,7 +47,7 @@ std::ostream& operator<<(std::ostream& os, const __float128& f)
namespace boost { namespace boost {
template <> template <>
struct has_left_shift<std::basic_ostream<char>, __float128> : public mpl::true_ struct has_left_shift<std::basic_ostream<char>, __float128> : public std::integral_constant<bool, true>
{}; {};
template <> template <>
+8 -8
View File
@@ -484,9 +484,9 @@ struct tester
private: private:
T generate_random() T generate_random()
{ {
return generate_random(boost::mpl::int_<Type>()); return generate_random(std::integral_constant<int, Type>());
} }
T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&) T generate_random(const std::integral_constant<int, boost::multiprecision::number_kind_floating_point>&)
{ {
T val = gen(); T val = gen();
T prev_val = -1; T prev_val = -1;
@@ -503,7 +503,7 @@ struct tester
static boost::random::uniform_int_distribution<e_type> ui(-30, 30); static boost::random::uniform_int_distribution<e_type> ui(-30, 30);
return ldexp(val, static_cast<int>(ui(gen))); return ldexp(val, static_cast<int>(ui(gen)));
} }
T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) T generate_random(const std::integral_constant<int, boost::multiprecision::number_kind_integer>&)
{ {
typedef boost::random::mt19937::result_type random_type; typedef boost::random::mt19937::result_type random_type;
@@ -535,7 +535,7 @@ struct tester
val %= max_val; val %= max_val;
return val; return val;
} }
T generate_random(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&) T generate_random(const std::integral_constant<int, boost::multiprecision::number_kind_rational>&)
{ {
typedef boost::random::mt19937::result_type random_type; typedef boost::random::mt19937::result_type random_type;
typedef typename boost::multiprecision::component_type<T>::type IntType; typedef typename boost::multiprecision::component_type<T>::type IntType;
@@ -584,15 +584,15 @@ struct tester
template <class N, int V> template <class N, int V>
boost::random::mt19937 tester<N, V>::gen; boost::random::mt19937 tester<N, V>::gen;
inline const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) inline const char* category_name(const std::integral_constant<int, boost::multiprecision::number_kind_integer>&)
{ {
return "integer"; return "integer";
} }
inline const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&) inline const char* category_name(const std::integral_constant<int, boost::multiprecision::number_kind_floating_point>&)
{ {
return "float"; return "float";
} }
inline const char* category_name(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&) inline const char* category_name(const std::integral_constant<int, boost::multiprecision::number_kind_rational>&)
{ {
return "rational"; return "rational";
} }
@@ -614,7 +614,7 @@ inline void report_result(const char* cat, const char* type, const char* op, uns
} }
template <class Number, int N> template <class Number, int N>
void test_int_ops(tester<Number, N>& t, const char* type, unsigned precision, const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) void test_int_ops(tester<Number, N>& t, const char* type, unsigned precision, const std::integral_constant<int, boost::multiprecision::number_kind_integer>&)
{ {
const char* cat = "integer"; const char* cat = "integer";
report_result(cat, type, "%", precision, t.test_mod()); report_result(cat, type, "%", precision, t.test_mod());
+4 -4
View File
@@ -43,9 +43,9 @@ struct skeleton_backend
// present in the list will get promoted to the next wider type that is // present in the list will get promoted to the next wider type that is
// in the list whenever mixed arithmetic involving that type is encountered. // in the list whenever mixed arithmetic involving that type is encountered.
// //
typedef mpl::list</*signed char, short, int, long,*/ long long> signed_types; typedef std::tuple</*signed char, short, int, long,*/ long long> signed_types;
typedef mpl::list</* unsigned char, unsigned short, unsigned, unsigned long,*/ unsigned long long> unsigned_types; typedef std::tuple</* unsigned char, unsigned short, unsigned, unsigned long,*/ unsigned long long> unsigned_types;
typedef mpl::list</*float, double,*/ long double> float_types; typedef std::tuple</*float, double,*/ long double> float_types;
// //
// This typedef is only required if this is a floating point type, it is the type // This typedef is only required if this is a floating point type, it is the type
// which holds the exponent: // which holds the exponent:
@@ -1088,7 +1088,7 @@ typedef number<skeleton_backend, et_off> skeleton_number;
// number_kind_complex // number_kind_complex
// //
template<> template<>
struct number_category<skeleton_backend > : public mpl::int_<number_kind_floating_point> struct number_category<skeleton_backend > : public std::integral_constant<int, number_kind_floating_point>
{}; {};
// //
+3 -3
View File
@@ -66,7 +66,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class T> template <class T>
void test_neg(const T& x, const boost::mpl::true_&) void test_neg(const T& x, const std::integral_constant<bool, true>&)
{ {
T val = -x; T val = -x;
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
@@ -115,7 +115,7 @@ void test_neg(const T& x, const boost::mpl::true_&)
#endif #endif
} }
template <class T> template <class T>
void test_neg(const T&, const boost::mpl::false_&) {} void test_neg(const T&, const std::integral_constant<bool, false>&) {}
template <class T> template <class T>
void test() void test()
@@ -173,7 +173,7 @@ void test()
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
} }
#endif #endif
test_neg(val, boost::mpl::bool_<std::numeric_limits<T>::is_signed>()); test_neg(val, std::integral_constant<bool, std::numeric_limits<T>::is_signed>());
// //
// Check to see if test is taking too long. // Check to see if test is taking too long.
// Tests run on the compiler farm time out after 300 seconds, // Tests run on the compiler farm time out after 300 seconds,
+48 -48
View File
@@ -14,10 +14,10 @@
#include "test.hpp" #include "test.hpp"
template <class T> template <class T>
struct is_boost_rational : public boost::mpl::false_ struct is_boost_rational : public std::integral_constant<bool, false>
{}; {};
template <class T> template <class T>
struct is_checked_cpp_int : public boost::mpl::false_ struct is_checked_cpp_int : public std::integral_constant<bool, false>
{}; {};
#ifdef BOOST_MSVC #ifdef BOOST_MSVC
@@ -63,7 +63,7 @@ abs(boost::multiprecision::detail::expression<tag, Arg1, Arg2, Arg3, Arg4> const
} // namespace detail } // namespace detail
template <class T> template <class T>
struct is_twos_complement_integer : public boost::mpl::true_ struct is_twos_complement_integer : public std::integral_constant<bool, true>
{}; {};
template <class T> template <class T>
@@ -229,7 +229,7 @@ void test_conditional(Real v, Exp e)
} }
template <class Real> template <class Real>
void test_complement(Real a, Real b, Real c, const boost::mpl::true_&) void test_complement(Real a, Real b, Real c, const std::integral_constant<bool, true>&)
{ {
int i = 1020304; int i = 1020304;
int j = 56789123; int j = 56789123;
@@ -249,7 +249,7 @@ void test_complement(Real a, Real b, Real c, const boost::mpl::true_&)
} }
template <class Real> template <class Real>
void test_complement(Real, Real, Real, const boost::mpl::false_&) void test_complement(Real, Real, Real, const std::integral_constant<bool, false>&)
{ {
} }
@@ -257,7 +257,7 @@ template <class Real, class T>
void test_integer_ops(const T&) {} void test_integer_ops(const T&) {}
template <class Real> template <class Real>
void test_rational(const boost::mpl::true_&) void test_rational(const std::integral_constant<bool, true>&)
{ {
Real a(2); Real a(2);
a /= 3; a /= 3;
@@ -277,7 +277,7 @@ void test_rational(const boost::mpl::true_&)
} }
template <class Real> template <class Real>
void test_rational(const boost::mpl::false_&) void test_rational(const std::integral_constant<bool, false>&)
{ {
Real a(2); Real a(2);
a /= 3; a /= 3;
@@ -303,13 +303,13 @@ void test_rational(const boost::mpl::false_&)
} }
template <class Real> template <class Real>
void test_integer_ops(const boost::mpl::int_<boost::multiprecision::number_kind_rational>&) void test_integer_ops(const std::integral_constant<int, boost::multiprecision::number_kind_rational>&)
{ {
test_rational<Real>(is_boost_rational<Real>()); test_rational<Real>(is_boost_rational<Real>());
} }
template <class Real> template <class Real>
void test_signed_integer_ops(const boost::mpl::true_&) void test_signed_integer_ops(const std::integral_constant<bool, true>&)
{ {
Real a(20); Real a(20);
Real b(7); Real b(7);
@@ -434,17 +434,17 @@ void test_signed_integer_ops(const boost::mpl::true_&)
#endif #endif
} }
template <class Real> template <class Real>
void test_signed_integer_ops(const boost::mpl::false_&) void test_signed_integer_ops(const std::integral_constant<bool, false>&)
{ {
} }
template <class Real> template <class Real>
inline Real negate_if_signed(Real r, const boost::mpl::bool_<true>&) inline Real negate_if_signed(Real r, const std::integral_constant<bool, true>&)
{ {
return -r; return -r;
} }
template <class Real> template <class Real>
inline Real negate_if_signed(Real r, const boost::mpl::bool_<false>&) inline Real negate_if_signed(Real r, const std::integral_constant<bool, false>&)
{ {
return r; return r;
} }
@@ -506,7 +506,7 @@ void test_integer_overflow()
m = 2u; m = 2u;
m = pow(m, (std::min)(std::numeric_limits<Real>::digits - 1, 1000)); m = pow(m, (std::min)(std::numeric_limits<Real>::digits - 1, 1000));
++m; ++m;
m = negate_if_signed(m, boost::mpl::bool_<std::numeric_limits<Real>::is_signed>()); m = negate_if_signed(m, std::integral_constant<bool, std::numeric_limits<Real>::is_signed>());
if (is_checked_cpp_int<Real>::value) if (is_checked_cpp_int<Real>::value)
{ {
BOOST_CHECK_THROW(m.template convert_to<Int>(), std::overflow_error); BOOST_CHECK_THROW(m.template convert_to<Int>(), std::overflow_error);
@@ -522,12 +522,12 @@ void test_integer_overflow()
// signed to unsigned converison with overflow, it's really not clear what should happen here! // signed to unsigned converison with overflow, it's really not clear what should happen here!
m = (std::numeric_limits<Int>::max)(); m = (std::numeric_limits<Int>::max)();
++m; ++m;
m = negate_if_signed(m, boost::mpl::bool_<std::numeric_limits<Real>::is_signed>()); m = negate_if_signed(m, std::integral_constant<bool, std::numeric_limits<Real>::is_signed>());
BOOST_CHECK_THROW(m.template convert_to<Int>(), std::range_error); BOOST_CHECK_THROW(m.template convert_to<Int>(), std::range_error);
// Again with much larger value: // Again with much larger value:
m = 2u; m = 2u;
m = pow(m, (std::min)(std::numeric_limits<Real>::digits - 1, 1000)); m = pow(m, (std::min)(std::numeric_limits<Real>::digits - 1, 1000));
m = negate_if_signed(m, boost::mpl::bool_<std::numeric_limits<Real>::is_signed>()); m = negate_if_signed(m, std::integral_constant<bool, std::numeric_limits<Real>::is_signed>());
BOOST_CHECK_THROW(m.template convert_to<Int>(), std::range_error); BOOST_CHECK_THROW(m.template convert_to<Int>(), std::range_error);
} }
} }
@@ -552,9 +552,9 @@ void test_integer_round_trip()
} }
template <class Real> template <class Real>
void test_integer_ops(const boost::mpl::int_<boost::multiprecision::number_kind_integer>&) void test_integer_ops(const std::integral_constant<int, boost::multiprecision::number_kind_integer>&)
{ {
test_signed_integer_ops<Real>(boost::mpl::bool_<std::numeric_limits<Real>::is_signed>()); test_signed_integer_ops<Real>(std::integral_constant<bool, std::numeric_limits<Real>::is_signed>());
Real a(20); Real a(20);
Real b(7); Real b(7);
@@ -958,7 +958,7 @@ template <class Real, class T>
void test_float_funcs(const T&) {} void test_float_funcs(const T&) {}
template <class Real> template <class Real>
void test_float_funcs(const boost::mpl::true_&) void test_float_funcs(const std::integral_constant<bool, true>&)
{ {
if (boost::multiprecision::is_interval_number<Real>::value) if (boost::multiprecision::is_interval_number<Real>::value)
return; return;
@@ -1198,7 +1198,7 @@ template <class Real, class T>
void test_float_ops(const T&) {} void test_float_ops(const T&) {}
template <class Real> template <class Real>
void test_float_ops(const boost::mpl::int_<boost::multiprecision::number_kind_floating_point>&) void test_float_ops(const std::integral_constant<int, boost::multiprecision::number_kind_floating_point>&)
{ {
BOOST_CHECK_EQUAL(abs(Real(2)), 2); BOOST_CHECK_EQUAL(abs(Real(2)), 2);
BOOST_CHECK_EQUAL(abs(Real(-2)), 2); BOOST_CHECK_EQUAL(abs(Real(-2)), 2);
@@ -1423,7 +1423,7 @@ void test_float_ops(const boost::mpl::int_<boost::multiprecision::number_kind_fl
} }
} }
test_float_funcs<Real>(boost::mpl::bool_<std::numeric_limits<Real>::is_specialized>()); test_float_funcs<Real>(std::integral_constant<bool, std::numeric_limits<Real>::is_specialized>());
} }
template <class T> template <class T>
@@ -1439,7 +1439,7 @@ struct lexical_cast_target_type
}; };
template <class Real, class Num> template <class Real, class Num>
void test_negative_mixed_minmax(boost::mpl::true_ const&) void test_negative_mixed_minmax(std::integral_constant<bool, true> const&)
{ {
if (!std::numeric_limits<Real>::is_bounded || (std::numeric_limits<Real>::digits >= std::numeric_limits<Num>::digits)) if (!std::numeric_limits<Real>::is_bounded || (std::numeric_limits<Real>::digits >= std::numeric_limits<Num>::digits))
{ {
@@ -1466,12 +1466,12 @@ void test_negative_mixed_minmax(boost::mpl::true_ const&)
} }
} }
template <class Real, class Num> template <class Real, class Num>
void test_negative_mixed_minmax(boost::mpl::false_ const&) void test_negative_mixed_minmax(std::integral_constant<bool, false> const&)
{ {
} }
template <class Real, class Num> template <class Real, class Num>
void test_negative_mixed_numeric_limits(boost::mpl::true_ const&) void test_negative_mixed_numeric_limits(std::integral_constant<bool, true> const&)
{ {
typedef typename lexical_cast_target_type<Num>::type target_type; typedef typename lexical_cast_target_type<Num>::type target_type;
#if defined(TEST_MPFR) #if defined(TEST_MPFR)
@@ -1498,10 +1498,10 @@ void test_negative_mixed_numeric_limits(boost::mpl::true_ const&)
} }
template <class Real, class Num> template <class Real, class Num>
void test_negative_mixed_numeric_limits(boost::mpl::false_ const&) {} void test_negative_mixed_numeric_limits(std::integral_constant<bool, false> const&) {}
template <class Real, class Num> template <class Real, class Num>
void test_negative_mixed(boost::mpl::true_ const&) void test_negative_mixed(std::integral_constant<bool, true> const&)
{ {
typedef typename std::conditional< typedef typename std::conditional<
std::is_convertible<Num, Real>::value, std::is_convertible<Num, Real>::value,
@@ -1552,7 +1552,7 @@ void test_negative_mixed(boost::mpl::true_ const&)
BOOST_CHECK_EQUAL(static_cast<Num>((Real(n2) + 0)), n2); BOOST_CHECK_EQUAL(static_cast<Num>((Real(n2) + 0)), n2);
BOOST_CHECK_EQUAL(static_cast<Num>((Real(n3) + 0)), n3); BOOST_CHECK_EQUAL(static_cast<Num>((Real(n3) + 0)), n3);
BOOST_CHECK_EQUAL(static_cast<Num>((Real(n4) + 0)), n4); BOOST_CHECK_EQUAL(static_cast<Num>((Real(n4) + 0)), n4);
test_negative_mixed_numeric_limits<Real, Num>(boost::mpl::bool_<std::numeric_limits<Real>::is_specialized>()); test_negative_mixed_numeric_limits<Real, Num>(std::integral_constant<bool, std::numeric_limits<Real>::is_specialized>());
// Assignment: // Assignment:
Real r(0); Real r(0);
BOOST_CHECK(r != static_cast<cast_type>(n1)); BOOST_CHECK(r != static_cast<cast_type>(n1));
@@ -1768,7 +1768,7 @@ void test_negative_mixed(boost::mpl::true_ const&)
// //
// Conversion from min and max values: // Conversion from min and max values:
// //
test_negative_mixed_minmax<Real, Num>(boost::mpl::bool_ < std::numeric_limits<Real>::is_integer && std::numeric_limits<Num>::is_integer > ()); test_negative_mixed_minmax<Real, Num>(std::integral_constant<bool, std::numeric_limits<Real>::is_integer && std::numeric_limits<Num>::is_integer > ());
// //
// RValue ref overloads: // RValue ref overloads:
// //
@@ -1794,38 +1794,38 @@ void test_negative_mixed(boost::mpl::true_ const&)
} }
template <class Real, class Num> template <class Real, class Num>
void test_negative_mixed(boost::mpl::false_ const&) void test_negative_mixed(std::integral_constant<bool, false> const&)
{ {
} }
template <class Real, class Num> template <class Real, class Num>
void test_mixed(const boost::mpl::false_&) void test_mixed(const std::integral_constant<bool, false>&)
{ {
} }
template <class Real> template <class Real>
inline bool check_is_nan(const Real& val, const boost::mpl::true_&) inline bool check_is_nan(const Real& val, const std::integral_constant<bool, true>&)
{ {
return (boost::math::isnan)(val); return (boost::math::isnan)(val);
} }
template <class Real> template <class Real>
inline bool check_is_nan(const Real&, const boost::mpl::false_&) inline bool check_is_nan(const Real&, const std::integral_constant<bool, false>&)
{ {
return false; return false;
} }
template <class Real> template <class Real>
inline Real negate_value(const Real& val, const boost::mpl::true_&) inline Real negate_value(const Real& val, const std::integral_constant<bool, true>&)
{ {
return -val; return -val;
} }
template <class Real> template <class Real>
inline Real negate_value(const Real& val, const boost::mpl::false_&) inline Real negate_value(const Real& val, const std::integral_constant<bool, false>&)
{ {
return val; return val;
} }
template <class Real, class Num> template <class Real, class Num>
void test_mixed_numeric_limits(const boost::mpl::true_&) void test_mixed_numeric_limits(const std::integral_constant<bool, true>&)
{ {
typedef typename lexical_cast_target_type<Num>::type target_type; typedef typename lexical_cast_target_type<Num>::type target_type;
#if defined(TEST_MPFR) #if defined(TEST_MPFR)
@@ -1839,15 +1839,15 @@ void test_mixed_numeric_limits(const boost::mpl::true_&)
{ {
d = static_cast<Real>(std::numeric_limits<Num>::infinity()); d = static_cast<Real>(std::numeric_limits<Num>::infinity());
BOOST_CHECK_GT(d, (std::numeric_limits<Real>::max)()); BOOST_CHECK_GT(d, (std::numeric_limits<Real>::max)());
d = static_cast<Real>(negate_value(std::numeric_limits<Num>::infinity(), boost::mpl::bool_<std::numeric_limits<Num>::is_signed>())); d = static_cast<Real>(negate_value(std::numeric_limits<Num>::infinity(), std::integral_constant<bool, std::numeric_limits<Num>::is_signed>()));
BOOST_CHECK_LT(d, negate_value((std::numeric_limits<Real>::max)(), boost::mpl::bool_<std::numeric_limits<Real>::is_signed>())); BOOST_CHECK_LT(d, negate_value((std::numeric_limits<Real>::max)(), std::integral_constant<bool, std::numeric_limits<Real>::is_signed>()));
} }
if (std::numeric_limits<Real>::has_quiet_NaN && std::numeric_limits<Num>::has_quiet_NaN) if (std::numeric_limits<Real>::has_quiet_NaN && std::numeric_limits<Num>::has_quiet_NaN)
{ {
d = static_cast<Real>(std::numeric_limits<Num>::quiet_NaN()); d = static_cast<Real>(std::numeric_limits<Num>::quiet_NaN());
BOOST_CHECK(check_is_nan(d, boost::mpl::bool_<std::numeric_limits<Real>::has_quiet_NaN>())); BOOST_CHECK(check_is_nan(d, std::integral_constant<bool, std::numeric_limits<Real>::has_quiet_NaN>()));
d = static_cast<Real>(negate_value(std::numeric_limits<Num>::quiet_NaN(), boost::mpl::bool_<std::numeric_limits<Num>::is_signed>())); d = static_cast<Real>(negate_value(std::numeric_limits<Num>::quiet_NaN(), std::integral_constant<bool, std::numeric_limits<Num>::is_signed>()));
BOOST_CHECK(check_is_nan(d, boost::mpl::bool_<std::numeric_limits<Real>::has_quiet_NaN>())); BOOST_CHECK(check_is_nan(d, std::integral_constant<bool, std::numeric_limits<Real>::has_quiet_NaN>()));
} }
static const int left_shift = std::numeric_limits<Num>::digits - 1; static const int left_shift = std::numeric_limits<Num>::digits - 1;
@@ -1869,12 +1869,12 @@ void test_mixed_numeric_limits(const boost::mpl::true_&)
BOOST_CHECK_CLOSE(n4, checked_lexical_cast<target_type>(Real(n4).str(digits_to_print, f)), 0); BOOST_CHECK_CLOSE(n4, checked_lexical_cast<target_type>(Real(n4).str(digits_to_print, f)), 0);
} }
template <class Real, class Num> template <class Real, class Num>
void test_mixed_numeric_limits(const boost::mpl::false_&) void test_mixed_numeric_limits(const std::integral_constant<bool, false>&)
{ {
} }
template <class Real, class Num> template <class Real, class Num>
void test_mixed(const boost::mpl::true_&) void test_mixed(const std::integral_constant<bool, true>&)
{ {
typedef typename std::conditional< typedef typename std::conditional<
std::is_convertible<Num, Real>::value, std::is_convertible<Num, Real>::value,
@@ -1976,7 +1976,7 @@ void test_mixed(const boost::mpl::true_&)
r = static_cast<cast_type>(Num(4) * n4) / Real(4); r = static_cast<cast_type>(Num(4) * n4) / Real(4);
BOOST_CHECK_EQUAL(r, static_cast<cast_type>(n4)); BOOST_CHECK_EQUAL(r, static_cast<cast_type>(n4));
typedef boost::mpl::bool_< typedef std::integral_constant<bool,
(!std::numeric_limits<Num>::is_specialized || std::numeric_limits<Num>::is_signed) && (!std::numeric_limits<Real>::is_specialized || std::numeric_limits<Real>::is_signed)> (!std::numeric_limits<Num>::is_specialized || std::numeric_limits<Num>::is_signed) && (!std::numeric_limits<Real>::is_specialized || std::numeric_limits<Real>::is_signed)>
signed_tag; signed_tag;
@@ -2053,7 +2053,7 @@ void test_mixed(const boost::mpl::true_&)
d = b * static_cast<cast_type>(n3) - static_cast<cast_type>(n1); d = b * static_cast<cast_type>(n3) - static_cast<cast_type>(n1);
BOOST_CHECK_EQUAL(d, 3 * 4 - 2); BOOST_CHECK_EQUAL(d, 3 * 4 - 2);
test_mixed_numeric_limits<Real, Num>(boost::mpl::bool_<std::numeric_limits<Real>::is_specialized>()); test_mixed_numeric_limits<Real, Num>(std::integral_constant<bool, std::numeric_limits<Real>::is_specialized>());
} }
template <class Real> template <class Real>
@@ -2535,7 +2535,7 @@ void test_members(boost::rational<Real>)
} }
template <class Real> template <class Real>
void test_signed_ops(const boost::mpl::true_&) void test_signed_ops(const std::integral_constant<bool, true>&)
{ {
Real a(8); Real a(8);
Real b(64); Real b(64);
@@ -2639,7 +2639,7 @@ void test_signed_ops(const boost::mpl::true_&)
BOOST_CHECK_EQUAL(c, -2); BOOST_CHECK_EQUAL(c, -2);
} }
template <class Real> template <class Real>
void test_signed_ops(const boost::mpl::false_&) void test_signed_ops(const std::integral_constant<bool, false>&)
{ {
} }
@@ -2857,11 +2857,11 @@ void test()
test_mixed<Real, long double>(tag); test_mixed<Real, long double>(tag);
typedef typename related_type<Real>::type related_type; typedef typename related_type<Real>::type related_type;
boost::mpl::bool_<boost::multiprecision::is_number<Real>::value && !std::is_same<related_type, Real>::value> tag2; std::integral_constant<bool, boost::multiprecision::is_number<Real>::value && !std::is_same<related_type, Real>::value> tag2;
test_mixed<Real, related_type>(tag2); test_mixed<Real, related_type>(tag2);
boost::mpl::bool_<boost::multiprecision::is_number<Real>::value && (boost::multiprecision::number_category<Real>::value == boost::multiprecision::number_kind_complex)> complex_tag; std::integral_constant<bool, boost::multiprecision::is_number<Real>::value && (boost::multiprecision::number_category<Real>::value == boost::multiprecision::number_kind_complex)> complex_tag;
test_mixed<Real, std::complex<float> >(complex_tag); test_mixed<Real, std::complex<float> >(complex_tag);
test_mixed<Real, std::complex<double> >(complex_tag); test_mixed<Real, std::complex<double> >(complex_tag);
test_mixed<Real, std::complex<long double> >(complex_tag); test_mixed<Real, std::complex<long double> >(complex_tag);
@@ -3136,7 +3136,7 @@ void test()
test_conditional(a, +a); test_conditional(a, +a);
test_conditional(a, (a + 0)); test_conditional(a, (a + 0));
test_signed_ops<Real>(boost::mpl::bool_<std::numeric_limits<Real>::is_signed>()); test_signed_ops<Real>(std::integral_constant<bool, std::numeric_limits<Real>::is_signed>());
// //
// Test hashing: // Test hashing:
// //
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
@@ -23,7 +23,7 @@ struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_int
}; };
template <> template <>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<64, 64, boost::multiprecision::unsigned_magnitude, boost::multiprecision::checked, void> > > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<64, 64, boost::multiprecision::unsigned_magnitude, boost::multiprecision::checked, void> > > : public std::integral_constant<bool, true>
{}; {};
int main() int main()
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
int main() int main()
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -10,7 +10,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
@@ -25,7 +25,7 @@ struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_int
}; };
template <> template <>
struct is_checked_cpp_int<boost::multiprecision::checked_cpp_int> : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::checked_cpp_int> : public std::integral_constant<bool, true>
{}; {};
int main() int main()
+2 -2
View File
@@ -8,11 +8,11 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
@@ -23,7 +23,7 @@ struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_int
}; };
template <> template <>
struct is_checked_cpp_int<boost::multiprecision::checked_uint1024_t> : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::checked_uint1024_t> : public std::integral_constant<bool, true>
{}; {};
int main() int main()
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -8,7 +8,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+1 -1
View File
@@ -10,7 +10,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
{}; {};
template <> template <>
+2 -2
View File
@@ -16,13 +16,13 @@
#include <boost/rational.hpp> #include <boost/rational.hpp>
template <class T> template <class T>
struct is_boost_rational<boost::rational<T> > : public boost::mpl::true_ struct is_boost_rational<boost::rational<T> > : public std::integral_constant<bool, true>
{}; {};
namespace boost { namespace multiprecision { namespace boost { namespace multiprecision {
template <> template <>
struct number_category<rational<mpz_int> > : public mpl::int_<number_kind_rational> struct number_category<rational<mpz_int> > : public std::integral_constant<int, number_kind_rational>
{}; {};
}} // namespace boost::multiprecision }} // namespace boost::multiprecision
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <> template <>
struct is_twos_complement_integer<boost::multiprecision::tom_int> : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::tom_int> : public std::integral_constant<bool, false>
{}; {};
int main() int main()
+2 -2
View File
@@ -17,13 +17,13 @@
#include <boost/rational.hpp> #include <boost/rational.hpp>
template <class T> template <class T>
struct is_boost_rational<boost::rational<T> > : public boost::mpl::true_ struct is_boost_rational<boost::rational<T> > : public std::integral_constant<bool, true>
{}; {};
namespace boost { namespace multiprecision { namespace boost { namespace multiprecision {
template <> template <>
struct number_category<rational<tom_int> > : public mpl::int_<number_kind_rational> struct number_category<rational<tom_int> > : public std::integral_constant<int, number_kind_rational>
{}; {};
}} // namespace boost::multiprecision }} // namespace boost::multiprecision
+1 -1
View File
@@ -12,7 +12,7 @@
#include "test_arithmetic.hpp" #include "test_arithmetic.hpp"
template <> template <>
struct is_twos_complement_integer<boost::multiprecision::tom_int> : public boost::mpl::false_ struct is_twos_complement_integer<boost::multiprecision::tom_int> : public std::integral_constant<bool, false>
{}; {};
int main() int main()
+2 -2
View File
@@ -74,12 +74,12 @@ T atan2_def(T y, T x)
} }
template <class T> template <class T>
struct is_mpfr_type : public boost::mpl::false_ struct is_mpfr_type : public std::integral_constant<bool, false>
{}; {};
#ifdef TEST_MPFR_50 #ifdef TEST_MPFR_50
template <unsigned Digits10> template <unsigned Digits10>
struct is_mpfr_type<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10> > > : public boost::mpl::true_ struct is_mpfr_type<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10> > > : public std::integral_constant<bool, true>
{}; {};
#endif #endif
+3 -3
View File
@@ -52,7 +52,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class Number> template <class Number>
void test_signed_overflow(Number a, Number b, const boost::mpl::true_&) void test_signed_overflow(Number a, Number b, const std::integral_constant<bool, true>&)
{ {
a = -a; a = -a;
BOOST_CHECK_THROW(Number(a * b), std::overflow_error); BOOST_CHECK_THROW(Number(a * b), std::overflow_error);
@@ -60,7 +60,7 @@ void test_signed_overflow(Number a, Number b, const boost::mpl::true_&)
BOOST_CHECK(Number(a * b) >= (std::numeric_limits<Number>::min)()); BOOST_CHECK(Number(a * b) >= (std::numeric_limits<Number>::min)());
} }
template <class Number> template <class Number>
void test_signed_overflow(Number, Number, const boost::mpl::false_&) void test_signed_overflow(Number, Number, const std::integral_constant<bool, false>&)
{ {
} }
@@ -112,7 +112,7 @@ void test()
val = static_cast<test_type>(generate_random<cpp_int>(bits)); val = static_cast<test_type>(generate_random<cpp_int>(bits));
test_type val2 = 1 + (std::numeric_limits<test_type>::max)() / val; test_type val2 = 1 + (std::numeric_limits<test_type>::max)() / val;
BOOST_CHECK_THROW(test_type(val2 * val), std::overflow_error); BOOST_CHECK_THROW(test_type(val2 * val), std::overflow_error);
test_signed_overflow(val2, val, boost::mpl::bool_<std::numeric_limits<test_type>::is_signed>()); test_signed_overflow(val2, val, std::integral_constant<bool, std::numeric_limits<test_type>::is_signed>());
--val2; --val2;
BOOST_CHECK(cpp_int(val2) * cpp_int(val) <= cpp_int((std::numeric_limits<test_type>::max)())); BOOST_CHECK(cpp_int(val2) * cpp_int(val) <= cpp_int((std::numeric_limits<test_type>::max)()));
BOOST_CHECK(val2 * val <= (std::numeric_limits<test_type>::max)()); BOOST_CHECK(val2 * val <= (std::numeric_limits<test_type>::max)());
+12 -12
View File
@@ -70,7 +70,7 @@ T generate_random()
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -79,12 +79,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(trunc(from)), From(t4)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t4));
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -93,12 +93,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(trunc(from)), From(t1)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
BOOST_CHECK_EQUAL(From(trunc(from)), From(t2)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -107,12 +107,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(t4), from); BOOST_CHECK_EQUAL(From(t4), from);
} }
template <class From, class To> template <class From, class To>
void test_convert_rat_int(From const&, const boost::mpl::false_&) void test_convert_rat_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -121,12 +121,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(t1), from); BOOST_CHECK_EQUAL(From(t1), from);
BOOST_CHECK_EQUAL(From(t2), from); BOOST_CHECK_EQUAL(From(t2), from);
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -137,12 +137,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -153,7 +153,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2; To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -57,7 +57,7 @@ T generate_random()
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -66,12 +66,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(trunc(from)), From(t4)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t4));
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -80,12 +80,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(trunc(from)), From(t1)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
BOOST_CHECK_EQUAL(From(trunc(from)), From(t2)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -95,12 +95,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(From(t4), from, tol); BOOST_CHECK_CLOSE_FRACTION(From(t4), from, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_rat_int(From const&, const boost::mpl::false_&) void test_convert_rat_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -110,12 +110,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
From tol = std::numeric_limits<From>::epsilon(); From tol = std::numeric_limits<From>::epsilon();
BOOST_CHECK_CLOSE_FRACTION(From(t1), from, tol); BOOST_CHECK_CLOSE_FRACTION(From(t1), from, tol);
BOOST_CHECK_CLOSE_FRACTION(From(t2), from, tol); BOOST_CHECK_CLOSE_FRACTION(From(t2), from, tol);
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -126,12 +126,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -142,7 +142,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2; To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -71,7 +71,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -80,12 +80,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), t4.str()); BOOST_CHECK_EQUAL(from.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -96,12 +96,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), t1.str()); BOOST_CHECK_EQUAL(from.str(), t1.str());
BOOST_CHECK_EQUAL(from.str(), t2.str()); BOOST_CHECK_EQUAL(from.str(), t2.str());
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -110,12 +110,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), numerator(t4).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t4).str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From const&, const boost::mpl::false_&) void test_convert_neg_rat(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -126,12 +126,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), numerator(t1).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t1).str());
BOOST_CHECK_EQUAL(from.str(), numerator(t2).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t2).str());
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -141,12 +141,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(t4, check); BOOST_CHECK_EQUAL(t4, check);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -158,7 +158,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To check(from.str() + ".0"); To check(from.str() + ".0");
BOOST_CHECK_EQUAL(t1, check); BOOST_CHECK_EQUAL(t1, check);
BOOST_CHECK_EQUAL(t2, check); BOOST_CHECK_EQUAL(t2, check);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -79,7 +79,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_val(From from, const boost::mpl::true_&) void test_convert_neg_val(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
typename component_type<From>::type answer = numerator(from) / denominator(from); typename component_type<From>::type answer = numerator(from) / denominator(from);
@@ -89,12 +89,12 @@ void test_convert_neg_val(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(answer.str(), t4.str()); BOOST_CHECK_EQUAL(answer.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_val(From const&, const boost::mpl::false_&) void test_convert_neg_val(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -106,12 +106,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(answer.str(), t1.str()); BOOST_CHECK_EQUAL(answer.str(), t1.str());
BOOST_CHECK_EQUAL(answer.str(), t2.str()); BOOST_CHECK_EQUAL(answer.str(), t2.str());
test_convert_neg_val<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_val<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float_val(From from, To const& tol, const boost::mpl::true_&) void test_convert_neg_float_val(From from, To const& tol, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To answer = To(numerator(from)) / To(denominator(from)); To answer = To(numerator(from)) / To(denominator(from));
@@ -121,12 +121,12 @@ void test_convert_neg_float_val(From from, To const& tol, const boost::mpl::true
BOOST_CHECK_CLOSE_FRACTION(answer, t4, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t4, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float_val(From const&, To const&, const boost::mpl::false_&) void test_convert_neg_float_val(From const&, To const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -140,12 +140,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
tol *= 2; tol *= 2;
BOOST_CHECK_CLOSE_FRACTION(answer, t1, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t1, tol);
BOOST_CHECK_CLOSE_FRACTION(answer, t2, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t2, tol);
test_convert_neg_float_val<From, To>(from, tol, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float_val<From, To>(from, tol, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat_val(From from, const boost::mpl::true_&) void test_convert_neg_rat_val(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -154,12 +154,12 @@ void test_convert_neg_rat_val(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), t4.str()); BOOST_CHECK_EQUAL(from.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat_val(From const&, const boost::mpl::false_&) void test_convert_neg_rat_val(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -170,7 +170,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), t1.str()); BOOST_CHECK_EQUAL(from.str(), t1.str());
BOOST_CHECK_EQUAL(from.str(), t2.str()); BOOST_CHECK_EQUAL(from.str(), t2.str());
test_convert_neg_rat_val<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat_val<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -59,7 +59,7 @@ T generate_random()
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -68,12 +68,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(trunc(from)), From(t4)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t4));
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -82,12 +82,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(trunc(from)), From(t1)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
BOOST_CHECK_EQUAL(From(trunc(from)), From(t2)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -96,12 +96,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(t4), from); BOOST_CHECK_EQUAL(From(t4), from);
} }
template <class From, class To> template <class From, class To>
void test_convert_rat_int(From const&, const boost::mpl::false_&) void test_convert_rat_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -110,12 +110,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(t1), from); BOOST_CHECK_EQUAL(From(t1), from);
BOOST_CHECK_EQUAL(From(t2), from); BOOST_CHECK_EQUAL(From(t2), from);
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -126,12 +126,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -142,7 +142,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2; To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -79,7 +79,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_val(From from, const boost::mpl::true_&) void test_convert_neg_val(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
typename component_type<From>::type answer = numerator(from) / denominator(from); typename component_type<From>::type answer = numerator(from) / denominator(from);
@@ -89,12 +89,12 @@ void test_convert_neg_val(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(answer.str(), t4.str()); BOOST_CHECK_EQUAL(answer.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_val(From const&, const boost::mpl::false_&) void test_convert_neg_val(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -106,12 +106,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(answer.str(), t1.str()); BOOST_CHECK_EQUAL(answer.str(), t1.str());
BOOST_CHECK_EQUAL(answer.str(), t2.str()); BOOST_CHECK_EQUAL(answer.str(), t2.str());
test_convert_neg_val<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_val<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float_val(From from, To const& tol, const boost::mpl::true_&) void test_convert_neg_float_val(From from, To const& tol, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To answer = To(numerator(from)) / To(denominator(from)); To answer = To(numerator(from)) / To(denominator(from));
@@ -121,12 +121,12 @@ void test_convert_neg_float_val(From from, To const& tol, const boost::mpl::true
BOOST_CHECK_CLOSE_FRACTION(answer, t4, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t4, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float_val(From const&, To const&, const boost::mpl::false_&) void test_convert_neg_float_val(From const&, To const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -140,12 +140,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
tol *= 2; tol *= 2;
BOOST_CHECK_CLOSE_FRACTION(answer, t1, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t1, tol);
BOOST_CHECK_CLOSE_FRACTION(answer, t2, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t2, tol);
test_convert_neg_float_val<From, To>(from, tol, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float_val<From, To>(from, tol, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat_val(From from, const boost::mpl::true_&) void test_convert_neg_rat_val(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -154,12 +154,12 @@ void test_convert_neg_rat_val(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), t4.str()); BOOST_CHECK_EQUAL(from.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat_val(From const&, const boost::mpl::false_&) void test_convert_neg_rat_val(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -170,7 +170,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), t1.str()); BOOST_CHECK_EQUAL(from.str(), t1.str());
BOOST_CHECK_EQUAL(from.str(), t2.str()); BOOST_CHECK_EQUAL(from.str(), t2.str());
test_convert_neg_rat_val<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat_val<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -59,7 +59,7 @@ T generate_random()
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -68,12 +68,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(trunc(from)), From(t4)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t4));
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -82,12 +82,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(trunc(from)), From(t1)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
BOOST_CHECK_EQUAL(From(trunc(from)), From(t2)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -97,12 +97,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(From(t4), from, tol); BOOST_CHECK_CLOSE_FRACTION(From(t4), from, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_rat_int(From const&, const boost::mpl::false_&) void test_convert_rat_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -112,12 +112,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
From tol = std::numeric_limits<From>::epsilon(); From tol = std::numeric_limits<From>::epsilon();
BOOST_CHECK_CLOSE_FRACTION(From(t1), from, tol); BOOST_CHECK_CLOSE_FRACTION(From(t1), from, tol);
BOOST_CHECK_CLOSE_FRACTION(From(t2), from, tol); BOOST_CHECK_CLOSE_FRACTION(From(t2), from, tol);
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -128,12 +128,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -144,7 +144,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2; To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -61,7 +61,7 @@ T generate_random()
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -70,12 +70,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(trunc(from)), From(t4)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t4));
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -84,12 +84,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(trunc(from)), From(t1)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
BOOST_CHECK_EQUAL(From(trunc(from)), From(t2)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -98,12 +98,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(t4), median(from)); BOOST_CHECK_EQUAL(From(t4), median(from));
} }
template <class From, class To> template <class From, class To>
void test_convert_rat_int(From const&, const boost::mpl::false_&) void test_convert_rat_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -112,12 +112,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(t1), median(from)); BOOST_CHECK_EQUAL(From(t1), median(from));
BOOST_CHECK_EQUAL(From(t2), median(from)); BOOST_CHECK_EQUAL(From(t2), median(from));
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -128,12 +128,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -144,7 +144,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2; To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -59,7 +59,7 @@ T generate_random()
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -68,12 +68,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(trunc(from)), From(t4)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t4));
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -82,12 +82,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(trunc(from)), From(t1)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t1));
BOOST_CHECK_EQUAL(From(trunc(from)), From(t2)); BOOST_CHECK_EQUAL(From(trunc(from)), From(t2));
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -96,12 +96,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(From(t4), from); BOOST_CHECK_EQUAL(From(t4), from);
} }
template <class From, class To> template <class From, class To>
void test_convert_rat_int(From const&, const boost::mpl::false_&) void test_convert_rat_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -110,12 +110,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(From(t1), from); BOOST_CHECK_EQUAL(From(t1), from);
BOOST_CHECK_EQUAL(From(t2), from); BOOST_CHECK_EQUAL(From(t2), from);
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -126,12 +126,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t4, answer, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_floating_point> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
for (unsigned i = 0; i < 100; ++i) for (unsigned i = 0; i < 100; ++i)
{ {
@@ -142,7 +142,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_floating_point> const&, boost
To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2; To tol = (std::max)(std::numeric_limits<To>::epsilon(), To(std::numeric_limits<From>::epsilon())) * 2;
BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t1, answer, tol);
BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol); BOOST_CHECK_CLOSE_FRACTION(t2, answer, tol);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -71,7 +71,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -80,12 +80,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), t4.str()); BOOST_CHECK_EQUAL(from.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -96,12 +96,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), t1.str()); BOOST_CHECK_EQUAL(from.str(), t1.str());
BOOST_CHECK_EQUAL(from.str(), t2.str()); BOOST_CHECK_EQUAL(from.str(), t2.str());
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -110,12 +110,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), numerator(t4).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t4).str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From const&, const boost::mpl::false_&) void test_convert_neg_rat(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -126,12 +126,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), numerator(t1).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t1).str());
BOOST_CHECK_EQUAL(from.str(), numerator(t2).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t2).str());
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -141,12 +141,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(t4, check); BOOST_CHECK_EQUAL(t4, check);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -158,7 +158,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To check(from.str() + ".0"); To check(from.str() + ".0");
BOOST_CHECK_EQUAL(t1, check); BOOST_CHECK_EQUAL(t1, check);
BOOST_CHECK_EQUAL(t2, check); BOOST_CHECK_EQUAL(t2, check);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -71,7 +71,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From from, const boost::mpl::true_&) void test_convert_neg_int(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -80,12 +80,12 @@ void test_convert_neg_int(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), t4.str()); BOOST_CHECK_EQUAL(from.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_int(From const&, const boost::mpl::false_&) void test_convert_neg_int(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -96,12 +96,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), t1.str()); BOOST_CHECK_EQUAL(from.str(), t1.str());
BOOST_CHECK_EQUAL(from.str(), t2.str()); BOOST_CHECK_EQUAL(from.str(), t2.str());
test_convert_neg_int<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_int<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From from, const boost::mpl::true_&) void test_convert_neg_rat(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -110,12 +110,12 @@ void test_convert_neg_rat(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), numerator(t4).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t4).str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat(From const&, const boost::mpl::false_&) void test_convert_neg_rat(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -126,12 +126,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), numerator(t1).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t1).str());
BOOST_CHECK_EQUAL(from.str(), numerator(t2).str()); BOOST_CHECK_EQUAL(from.str(), numerator(t2).str());
test_convert_neg_rat<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From from, const boost::mpl::true_&) void test_convert_neg_float(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -141,12 +141,12 @@ void test_convert_neg_float(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(t4, check); BOOST_CHECK_EQUAL(t4, check);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float(From const&, const boost::mpl::false_&) void test_convert_neg_float(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_integer> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -158,7 +158,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_integer> const&, boost::mpl::
To check(from.str() + ".0"); To check(from.str() + ".0");
BOOST_CHECK_EQUAL(t1, check); BOOST_CHECK_EQUAL(t1, check);
BOOST_CHECK_EQUAL(t2, check); BOOST_CHECK_EQUAL(t2, check);
test_convert_neg_float<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+12 -12
View File
@@ -79,7 +79,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_val(From from, const boost::mpl::true_&) void test_convert_neg_val(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
typename component_type<From>::type answer = numerator(from) / denominator(from); typename component_type<From>::type answer = numerator(from) / denominator(from);
@@ -89,12 +89,12 @@ void test_convert_neg_val(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(answer.str(), t4.str()); BOOST_CHECK_EQUAL(answer.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_val(From const&, const boost::mpl::false_&) void test_convert_neg_val(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_integer> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_integer> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -106,12 +106,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(answer.str(), t1.str()); BOOST_CHECK_EQUAL(answer.str(), t1.str());
BOOST_CHECK_EQUAL(answer.str(), t2.str()); BOOST_CHECK_EQUAL(answer.str(), t2.str());
test_convert_neg_val<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_val<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float_val(From from, To const& tol, const boost::mpl::true_&) void test_convert_neg_float_val(From from, To const& tol, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To answer = To(numerator(from)) / To(denominator(from)); To answer = To(numerator(from)) / To(denominator(from));
@@ -121,12 +121,12 @@ void test_convert_neg_float_val(From from, To const& tol, const boost::mpl::true
BOOST_CHECK_CLOSE_FRACTION(answer, t4, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t4, tol);
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_float_val(From const&, To const&, const boost::mpl::false_&) void test_convert_neg_float_val(From const&, To const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_floating_point> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_floating_point> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -140,12 +140,12 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
tol *= 2; tol *= 2;
BOOST_CHECK_CLOSE_FRACTION(answer, t1, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t1, tol);
BOOST_CHECK_CLOSE_FRACTION(answer, t2, tol); BOOST_CHECK_CLOSE_FRACTION(answer, t2, tol);
test_convert_neg_float_val<From, To>(from, tol, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_float_val<From, To>(from, tol, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat_val(From from, const boost::mpl::true_&) void test_convert_neg_rat_val(From from, const std::integral_constant<bool, true>&)
{ {
from = -from; from = -from;
To t3(from); To t3(from);
@@ -154,12 +154,12 @@ void test_convert_neg_rat_val(From from, const boost::mpl::true_&)
BOOST_CHECK_EQUAL(from.str(), t4.str()); BOOST_CHECK_EQUAL(from.str(), t4.str());
} }
template <class From, class To> template <class From, class To>
void test_convert_neg_rat_val(From const&, const boost::mpl::false_&) void test_convert_neg_rat_val(From const&, const std::integral_constant<bool, false>&)
{ {
} }
template <class From, class To> template <class From, class To>
void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl::int_<number_kind_rational> const&) void test_convert_imp(std::integral_constant<int, number_kind_rational> const&, std::integral_constant<int, number_kind_rational> const&)
{ {
int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000); int bits_wanted = (std::min)((std::min)(std::numeric_limits<From>::digits, std::numeric_limits<To>::digits), 2000);
@@ -170,7 +170,7 @@ void test_convert_imp(boost::mpl::int_<number_kind_rational> const&, boost::mpl:
To t2 = from.template convert_to<To>(); To t2 = from.template convert_to<To>();
BOOST_CHECK_EQUAL(from.str(), t1.str()); BOOST_CHECK_EQUAL(from.str(), t1.str());
BOOST_CHECK_EQUAL(from.str(), t2.str()); BOOST_CHECK_EQUAL(from.str(), t2.str());
test_convert_neg_rat_val<From, To>(from, boost::mpl::bool_ < std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ()); test_convert_neg_rat_val<From, To>(from, std::integral_constant<bool, std::numeric_limits<From>::is_signed && std::numeric_limits<To>::is_signed > ());
} }
} }
+2 -2
View File
@@ -73,10 +73,10 @@ T generate_random(unsigned bits_wanted)
} }
template <class T> template <class T>
struct is_checked_cpp_int : public boost::mpl::false_ struct is_checked_cpp_int : public std::integral_constant<bool, false>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <class Number> template <class Number>
+3 -3
View File
@@ -53,7 +53,7 @@ T generate_random()
} }
template <class T> template <class T>
void test_round_trip_neg(T val, const boost::mpl::true_&) void test_round_trip_neg(T val, const std::integral_constant<bool, true>&)
{ {
// Try some negative values: // Try some negative values:
std::vector<unsigned char> cv; std::vector<unsigned char> cv;
@@ -65,7 +65,7 @@ void test_round_trip_neg(T val, const boost::mpl::true_&)
} }
template <class T> template <class T>
void test_round_trip_neg(const T&, const boost::mpl::false_&) void test_round_trip_neg(const T&, const std::integral_constant<bool, false>&)
{ {
} }
@@ -137,7 +137,7 @@ void test_round_trip(T val)
import_bits(newval, cv.begin(), cv.end(), 6, false); import_bits(newval, cv.begin(), cv.end(), 6, false);
BOOST_CHECK_EQUAL(val, newval); BOOST_CHECK_EQUAL(val, newval);
test_round_trip_neg(val, boost::mpl::bool_<std::numeric_limits<T>::is_signed>()); test_round_trip_neg(val, std::integral_constant<bool, std::numeric_limits<T>::is_signed>());
} }
template <class T> template <class T>
+2 -2
View File
@@ -68,10 +68,10 @@ T generate_random(unsigned bits_wanted)
} }
template <class T> template <class T>
struct is_checked_cpp_int : public boost::mpl::false_ struct is_checked_cpp_int : public std::integral_constant<bool, false>
{}; {};
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET> template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ET>
struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public boost::mpl::true_ struct is_checked_cpp_int<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ET> > : public std::integral_constant<bool, true>
{}; {};
template <class N> template <class N>
+4 -4
View File
@@ -72,12 +72,12 @@ void test_value(const T& val)
} }
} }
void test(const boost::mpl::int_<200>&) {} void test(const std::integral_constant<int, 200>&) {}
template <int N> template <int N>
void test(boost::mpl::int_<N> const&) void test(std::integral_constant<int, N> const&)
{ {
test(boost::mpl::int_<N + 4>()); test(std::integral_constant<int, N + 4>());
typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude>, boost::multiprecision::et_off> mp_type; typedef boost::multiprecision::number<boost::multiprecision::cpp_int_backend<N, N, boost::multiprecision::unsigned_magnitude>, boost::multiprecision::et_off> mp_type;
@@ -92,6 +92,6 @@ void test(boost::mpl::int_<N> const&)
int main() int main()
{ {
test(boost::mpl::int_<24>()); test(std::integral_constant<int, 24>());
return boost::report_errors(); return boost::report_errors();
} }
+3 -3
View File
@@ -64,7 +64,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class T> template <class T>
void test_neg(const T& x, const boost::mpl::true_&) void test_neg(const T& x, const std::integral_constant<bool, true>&)
{ {
T val = -x; T val = -x;
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
@@ -100,7 +100,7 @@ void test_neg(const T& x, const boost::mpl::true_&)
#endif #endif
} }
template <class T> template <class T>
void test_neg(const T&, const boost::mpl::false_&) {} void test_neg(const T&, const std::integral_constant<bool, false>&) {}
template <class T> template <class T>
void test() void test()
@@ -159,7 +159,7 @@ void test()
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
} }
#endif #endif
test_neg(val, boost::mpl::bool_<std::numeric_limits<T>::is_signed>()); test_neg(val, std::integral_constant<bool, std::numeric_limits<T>::is_signed>());
// //
// Check to see if test is taking too long. // Check to see if test is taking too long.
// Tests run on the compiler farm time out after 300 seconds, // Tests run on the compiler farm time out after 300 seconds,
+3 -3
View File
@@ -66,7 +66,7 @@ T generate_random(unsigned bits_wanted)
} }
template <class T> template <class T>
void test_neg(const T& x, const boost::mpl::true_&) void test_neg(const T& x, const std::integral_constant<bool, true>&)
{ {
T val = -x; T val = -x;
#ifndef BOOST_NO_EXCEPTIONS #ifndef BOOST_NO_EXCEPTIONS
@@ -115,7 +115,7 @@ void test_neg(const T& x, const boost::mpl::true_&)
#endif #endif
} }
template <class T> template <class T>
void test_neg(const T&, const boost::mpl::false_&) {} void test_neg(const T&, const std::integral_constant<bool, false>&) {}
template <class T> template <class T>
void test() void test()
@@ -160,7 +160,7 @@ void test()
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
} }
#endif #endif
test_neg(val, boost::mpl::bool_<std::numeric_limits<T>::is_signed>()); test_neg(val, std::integral_constant<bool, std::numeric_limits<T>::is_signed>());
// //
// Check to see if test is taking too long. // Check to see if test is taking too long.
+3 -3
View File
@@ -52,18 +52,18 @@ struct NumTraits<boost::multiprecision::number<Backend, ExpressionTemplates> >
{ {
return (std::numeric_limits<Real>::min)(); return (std::numeric_limits<Real>::min)();
} }
static int digits10_imp(const boost::mpl::true_&) static int digits10_imp(const std::integral_constant<bool, true>&)
{ {
return std::numeric_limits<Real>::digits10; return std::numeric_limits<Real>::digits10;
} }
template <bool B> template <bool B>
static int digits10_imp(const boost::mpl::bool_<B>&) static int digits10_imp(const std::integral_constant<bool, B>&)
{ {
return Real::default_precision(); return Real::default_precision();
} }
static int digits10() static int digits10()
{ {
return digits10_imp(boost::mpl::bool_ < std::numeric_limits<Real>::digits10 && (std::numeric_limits<Real>::digits10 != INT_MAX) ? true : false > ()); return digits10_imp(std::integral_constant<bool, std::numeric_limits<Real>::digits10 && (std::numeric_limits<Real>::digits10 != INT_MAX) ? true : false > ());
} }
}; };
+6 -6
View File
@@ -104,17 +104,17 @@ void do_round_trip(const T& val)
} }
template <class T> template <class T>
void negative_round_trip(T val, const boost::mpl::true_&) void negative_round_trip(T val, const std::integral_constant<bool, true>&)
{ {
do_round_trip(T(-val)); do_round_trip(T(-val));
} }
template <class T> template <class T>
void negative_round_trip(T, const boost::mpl::false_&) void negative_round_trip(T, const std::integral_constant<bool, false>&)
{ {
} }
template <class T> template <class T>
void negative_spots(const boost::mpl::true_&) void negative_spots(const std::integral_constant<bool, true>&)
{ {
BOOST_CHECK_EQUAL(T(-1002).str(), "-1002"); BOOST_CHECK_EQUAL(T(-1002).str(), "-1002");
if (!std::numeric_limits<T>::is_modulo) if (!std::numeric_limits<T>::is_modulo)
@@ -126,7 +126,7 @@ void negative_spots(const boost::mpl::true_&)
} }
} }
template <class T> template <class T>
void negative_spots(const boost::mpl::false_&) void negative_spots(const std::integral_constant<bool, false>&)
{ {
} }
@@ -137,7 +137,7 @@ void test_round_trip()
{ {
T val = generate_random<T>(); T val = generate_random<T>();
do_round_trip(val); do_round_trip(val);
negative_round_trip(val, boost::mpl::bool_<std::numeric_limits<T>::is_signed>()); negative_round_trip(val, std::integral_constant<bool, std::numeric_limits<T>::is_signed>());
} }
BOOST_CHECK_EQUAL(T(1002).str(), "1002"); BOOST_CHECK_EQUAL(T(1002).str(), "1002");
@@ -151,7 +151,7 @@ void test_round_trip()
BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec), "1002"); BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec), "1002");
BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec | std::ios_base::showbase), "1002"); BOOST_CHECK_EQUAL(T(1002).str(0, std::ios_base::dec | std::ios_base::showbase), "1002");
negative_spots<T>(boost::mpl::bool_<std::numeric_limits<T>::is_signed>()); negative_spots<T>(std::integral_constant<bool, std::numeric_limits<T>::is_signed>());
} }
int main() int main()
+3 -3
View File
@@ -9,7 +9,7 @@
#include "test.hpp" #include "test.hpp"
template <class Big, class Small> template <class Big, class Small>
void test_floats(const boost::mpl::true_) void test_floats(const std::integral_constant<bool, true>)
{ {
Big big_val = boost::math::constants::pi<Big>(); Big big_val = boost::math::constants::pi<Big>();
Small small = boost::math::constants::pi<Small>(); Small small = boost::math::constants::pi<Small>();
@@ -47,7 +47,7 @@ void test_floats(const boost::mpl::true_)
} }
template <class Big, class Small> template <class Big, class Small>
void test_floats(const boost::mpl::false_){} void test_floats(const std::integral_constant<bool, false>){}
template <class Big, class Small> template <class Big, class Small>
void test() void test()
@@ -227,7 +227,7 @@ void test()
BOOST_CHECK_EQUAL((big_val * 1) * (small_val * 1), (big_val * 1) * Big((small_val * 1))); BOOST_CHECK_EQUAL((big_val * 1) * (small_val * 1), (big_val * 1) * Big((small_val * 1)));
BOOST_CHECK_EQUAL((big_val * 1) / (small_val * 1), (big_val * 1) / Big((small_val * 1))); BOOST_CHECK_EQUAL((big_val * 1) / (small_val * 1), (big_val * 1) / Big((small_val * 1)));
test_floats<Big, Small>(boost::mpl::bool_<boost::multiprecision::number_category<Big>::value == boost::multiprecision::number_kind_floating_point>()); test_floats<Big, Small>(std::integral_constant<bool, boost::multiprecision::number_category<Big>::value == boost::multiprecision::number_kind_floating_point>());
} }
#endif // BOOST_MATH_TEST_MIXED_HPP #endif // BOOST_MATH_TEST_MIXED_HPP

Some files were not shown because too many files have changed in this diff Show More