diff --git a/ref_app/src/math/wide_decimal/decwide_t.h b/ref_app/src/math/wide_decimal/decwide_t.h index 8d22db6f3..e4695e41c 100644 --- a/ref_app/src/math/wide_decimal/decwide_t.h +++ b/ref_app/src/math/wide_decimal/decwide_t.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 1999 - 2024. // +// Copyright Christopher Kormanyos 1999 - 2025. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -74,22 +74,22 @@ #endif // Forward declarations of various decwide_t namespace functions. - template + template constexpr auto zero() -> decwide_t; - template + template constexpr auto one() -> decwide_t; - template + template constexpr auto two() -> decwide_t; - template + template constexpr auto half() -> decwide_t; #if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS) - template, + template, typename InternalFloatType = double, typename ExponentType = std::int64_t, typename FftFloatType = double> @@ -99,7 +99,7 @@ auto pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> const decwide_t&; #endif #else - template, typename InternalFloatType = double, @@ -113,7 +113,7 @@ #endif #if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS) - template, typename InternalFloatType = double, @@ -121,7 +121,7 @@ typename FftFloatType = double> auto ln_two() -> const decwide_t&; #else - template, typename InternalFloatType = double, @@ -130,7 +130,7 @@ auto ln_two() -> decwide_t; #endif - template, typename InternalFloatType = double, @@ -142,7 +142,7 @@ auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT8_C(51))), decwide_t>::type; #endif - template, typename InternalFloatType = double, @@ -154,7 +154,7 @@ auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; #endif - template, typename InternalFloatType = double, @@ -166,7 +166,7 @@ auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; #endif - template, typename InternalFloatType = double, @@ -178,7 +178,7 @@ auto calc_pi(void(*pfn_callback_to_report_digits10)(const std::uint32_t) = nullptr) -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; #endif - template, typename InternalFloatType = double, @@ -186,7 +186,7 @@ typename FftFloatType = double> auto calc_ln_two() -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT8_C(51))), decwide_t>::type; - template, typename InternalFloatType = double, @@ -194,7 +194,7 @@ typename FftFloatType = double> auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; - template, typename InternalFloatType = double, @@ -202,7 +202,7 @@ typename FftFloatType = double> auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; - template, typename InternalFloatType = double, @@ -210,7 +210,7 @@ typename FftFloatType = double> auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; - template, typename InternalFloatType = double, @@ -218,7 +218,7 @@ typename FftFloatType = double> auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; - template, typename InternalFloatType = double, @@ -226,7 +226,7 @@ typename FftFloatType = double> auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; - template, typename InternalFloatType = double, @@ -234,273 +234,273 @@ typename FftFloatType = double> auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type; - template auto constexpr unsigned_long_long_max() -> decwide_t; - template auto constexpr signed_long_long_min () -> decwide_t; - template auto constexpr signed_long_long_max () -> decwide_t; - template auto constexpr long_double_min () -> decwide_t; - template auto constexpr long_double_max () -> decwide_t; - - template auto (isnan) (const decwide_t& x) -> bool; - template auto (isfinite)(const decwide_t& x) -> bool; - template auto (isinf) (const decwide_t& x) -> bool; - template auto (signbit) (const decwide_t& x) -> bool; - - template auto fabs (const decwide_t& x) -> decwide_t; - template auto abs (const decwide_t& x) -> decwide_t; - template auto floor (const decwide_t& x) -> decwide_t; - template auto ceil (const decwide_t& x) -> decwide_t; - template auto ldexp (const decwide_t& v, + template auto constexpr unsigned_long_long_max() -> decwide_t; + template auto constexpr signed_long_long_min () -> decwide_t; + template auto constexpr signed_long_long_max () -> decwide_t; + template auto constexpr long_double_min () -> decwide_t; + template auto constexpr long_double_max () -> decwide_t; + + template auto (isnan) (const decwide_t& x) -> bool; + template auto (isfinite)(const decwide_t& x) -> bool; + template auto (isinf) (const decwide_t& x) -> bool; + template auto (signbit) (const decwide_t& x) -> bool; + + template auto fabs (const decwide_t& x) -> decwide_t; + template auto abs (const decwide_t& x) -> decwide_t; + template auto floor (const decwide_t& x) -> decwide_t; + template auto ceil (const decwide_t& x) -> decwide_t; + template auto ldexp (const decwide_t& v, int e) -> decwide_t; - template auto frexp (const decwide_t& v, + template auto frexp (const decwide_t& v, int* expon) -> decwide_t; - template auto fmod (const decwide_t& v1, + template auto fmod (const decwide_t& v1, const decwide_t& v2) -> decwide_t; - template auto ilogb (const decwide_t& x) -> typename decwide_t::exponent_type; - template auto sqrt (const decwide_t& x) -> decwide_t; - template auto cbrt (const decwide_t& x) -> decwide_t; - template auto rootn (const decwide_t& x, // NOLINT(misc-no-recursion) + template auto ilogb (const decwide_t& x) -> typename decwide_t::exponent_type; + template auto sqrt (const decwide_t& x) -> decwide_t; + template auto cbrt (const decwide_t& x) -> decwide_t; + template auto rootn (const decwide_t& x, // NOLINT(misc-no-recursion) std::int32_t p) -> decwide_t; - template auto rootn_inv(const decwide_t& x, + template auto rootn_inv(const decwide_t& x, std::int32_t p) -> decwide_t; - template auto log (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT8_C(51))), decwide_t>::type; // NOLINT(misc-no-recursion) - template auto log (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast(INT8_C(51))), decwide_t>::type; // NOLINT(misc-no-recursion) - template auto exp (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT32_C(2000))), decwide_t>::type; - template auto exp (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast(INT32_C(2000))), decwide_t>::type; - template auto sinh (const decwide_t& x) -> decwide_t; - template auto cosh (const decwide_t& x) -> decwide_t; - template auto tanh (const decwide_t& x) -> decwide_t; - template auto pow (const decwide_t& b, // NOLINT(misc-no-recursion) + template auto log (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT8_C(51))), decwide_t>::type; // NOLINT(misc-no-recursion) + template auto log (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast(INT8_C(51))), decwide_t>::type; // NOLINT(misc-no-recursion) + template auto exp (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT32_C(2000))), decwide_t>::type; + template auto exp (const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast(INT32_C(2000))), decwide_t>::type; + template auto sinh (const decwide_t& x) -> decwide_t; + template auto cosh (const decwide_t& x) -> decwide_t; + template auto tanh (const decwide_t& x) -> decwide_t; + template auto pow (const decwide_t& b, // NOLINT(misc-no-recursion) std::int64_t p) -> decwide_t; - template auto pow (const decwide_t& x, + template auto pow (const decwide_t& x, const decwide_t& a) -> decwide_t; #if !defined(WIDE_DECIMAL_DISABLE_IOSTREAM) template auto operator<<(std::basic_ostream& os, const decwide_t& f) -> std::basic_ostream&; + const ::std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator<<(std::basic_ostream& os, const decwide_t& f) -> std::basic_ostream&; #if !defined(WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING) template auto operator>>(std::basic_istream& is, decwide_t& f) -> std::basic_istream&; + const ::std::int32_t ParamDigitsBaseTen, typename LimbType, typename AllocatorType, typename InternalFloatType, typename ExponentType, typename FftFloatType> auto operator>>(std::basic_istream& is, decwide_t& f) -> std::basic_istream&; #endif // !WIDE_DECIMAL_DISABLE_CONSTRUCT_FROM_STRING #endif // !WIDE_DECIMAL_DISABLE_IOSTREAM // Global unary operators of decwide_t reference. - template auto operator+(const decwide_t& self) -> decwide_t; - template auto operator-(const decwide_t& self) -> decwide_t; + template auto operator+(const decwide_t& self) -> decwide_t; + template auto operator-(const decwide_t& self) -> decwide_t; // Global add/sub/mul/div of const decwide_t& with const decwide_t&. - template auto operator+(const decwide_t& u, const decwide_t& v) -> decwide_t; - template auto operator-(const decwide_t& u, const decwide_t& v) -> decwide_t; - template auto operator*(const decwide_t& u, const decwide_t& v) -> decwide_t; - template auto operator/(const decwide_t& u, const decwide_t& v) -> decwide_t; + template auto operator+(const decwide_t& u, const decwide_t& v) -> decwide_t; + template auto operator-(const decwide_t& u, const decwide_t& v) -> decwide_t; + template auto operator*(const decwide_t& u, const decwide_t& v) -> decwide_t; + template auto operator/(const decwide_t& u, const decwide_t& v) -> decwide_t; // Global add/sub/mul/div of const decwide_t& with all built-in types. - template + template auto operator+(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator+(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator+(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator-(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator-(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator-(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator*(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator*(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator*(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator/(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator/(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator/(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; // Global add/sub/mul/div of all built-in types with const decwide_t&. - template + template auto operator+(SignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator+(UnsignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator+(FloatingPointType f, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator-(ArithmeticType n, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator*(SignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator*(UnsignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator*(FloatingPointType f, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator/(ArithmeticType n, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type; // Global self add/sub/mul/div of decwide_t& with all built-in types. - template + template auto operator+=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator+=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator+=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator-=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator-=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator-=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator*=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator*=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator*=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; - template + template auto operator/=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), decwide_t>::type; - template + template auto operator/=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, decwide_t>::type; - template + template auto operator/=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type; // Global comparison operators of const decwide_t& with const decwide_t&. - template auto operator< (const decwide_t& u, const decwide_t& v) -> bool; - template auto operator<=(const decwide_t& u, const decwide_t& v) -> bool; - template auto operator==(const decwide_t& u, const decwide_t& v) -> bool; - template auto operator!=(const decwide_t& u, const decwide_t& v) -> bool; - template auto operator>=(const decwide_t& u, const decwide_t& v) -> bool; - template auto operator> (const decwide_t& u, const decwide_t& v) -> bool; + template auto operator< (const decwide_t& u, const decwide_t& v) -> bool; + template auto operator<=(const decwide_t& u, const decwide_t& v) -> bool; + template auto operator==(const decwide_t& u, const decwide_t& v) -> bool; + template auto operator!=(const decwide_t& u, const decwide_t& v) -> bool; + template auto operator>=(const decwide_t& u, const decwide_t& v) -> bool; + template auto operator> (const decwide_t& u, const decwide_t& v) -> bool; // Global comparison operators of const decwide_t& with all built-in types. - template auto operator< (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; - template auto operator<=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; - template auto operator==(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; - template auto operator!=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; - template auto operator>=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; - template auto operator> (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; + template auto operator< (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; + template auto operator<=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; + template auto operator==(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; + template auto operator!=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; + template auto operator>=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; + template auto operator> (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type; // Global comparison operators of all built-in types with const decwide_t&. - template auto operator< (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; - template auto operator<=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; - template auto operator==(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; - template auto operator!=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; - template auto operator>=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; - template auto operator> (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; - - template auto operator< (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; + template auto operator<=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; + template auto operator==(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; + template auto operator!=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; + template auto operator>=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; + template auto operator> (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type; + + template void + auto precision(const ::std::int32_t prec_digits) noexcept -> void { const auto prec_digits_elem_digits10_div = static_cast(prec_digits / decwide_t_elem_digits10); const auto prec_digits_elem_digits10_mod = static_cast(prec_digits % decwide_t_elem_digits10); @@ -2777,11 +2777,11 @@ my_neg = b_neg; } - template + template auto eval_mul_dispatch_multiplication_method ( const decwide_t& v, - const std::int32_t prec_elems_for_multiply, + const ::std::int32_t prec_elems_for_multiply, const typename std::enable_if<( (OtherDigits10 == ParamDigitsBaseTen) && !(decwide_t::decwide_t_elem_number >= decwide_t_elems_for_kara))>::type* p_nullparam = nullptr ) -> void @@ -2834,11 +2834,11 @@ } } - template + template auto eval_mul_dispatch_multiplication_method ( const decwide_t& v, - const std::int32_t prec_elems_for_multiply, + const ::std::int32_t prec_elems_for_multiply, const typename std::enable_if<( (OtherDigits10 == ParamDigitsBaseTen) && (decwide_t::decwide_t_elem_number >= decwide_t_elems_for_kara) && (decwide_t::decwide_t_elem_number < decwide_t_elems_for_fft))>::type* p_nullparam = nullptr @@ -2956,11 +2956,11 @@ } } - template + template auto eval_mul_dispatch_multiplication_method ( const decwide_t& v, - const std::int32_t prec_elems_for_multiply, + const ::std::int32_t prec_elems_for_multiply, const typename std::enable_if<( (OtherDigits10 == ParamDigitsBaseTen) && (decwide_t::decwide_t_elem_number >= decwide_t_elems_for_fft))>::type* p_nullparam = nullptr ) -> void @@ -4274,16 +4274,16 @@ return static_cast(x.my_exp + exp10_val); } - template + template friend constexpr auto zero() -> decwide_t; // NOLINT(readability-redundant-declaration) - template + template friend constexpr auto one() -> decwide_t; // NOLINT(readability-redundant-declaration) - template + template friend constexpr auto two() -> decwide_t; // NOLINT(readability-redundant-declaration) - template + template friend constexpr auto half() -> decwide_t; // NOLINT(readability-redundant-declaration) }; @@ -4293,7 +4293,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overread" #endif - template + template constexpr auto zero() -> decwide_t { using other_wide_decimal_type = @@ -4308,7 +4308,7 @@ #pragma GCC diagnostic pop #endif - template + template constexpr auto one() -> decwide_t { using other_wide_decimal_type = @@ -4319,7 +4319,7 @@ return other_wide_decimal_type::from_lst( { static_cast(UINT8_C(1)) } ); } - template + template constexpr auto two() -> decwide_t { using other_wide_decimal_type = @@ -4330,7 +4330,7 @@ return other_wide_decimal_type::from_lst( { static_cast(UINT8_C(2)) } ); } - template + template constexpr auto half() -> decwide_t { using other_wide_decimal_type = @@ -4349,38 +4349,38 @@ ); } - template constexpr std::int32_t decwide_t::decwide_t_digits10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_digits; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_max_digits10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_radix; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_elem_digits10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_elem_number; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_elem_mask; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_elem_mask_half; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_elems_for_kara; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr std::int32_t decwide_t::decwide_t_elems_for_fft; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - - template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_max_exp10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_min_exp10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_max_exp; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) - template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_min_exp; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_digits10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_digits; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_max_digits10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_radix; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_elem_digits10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_elem_number; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_elem_mask; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_elem_mask_half; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_elems_for_kara; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr std::int32_t decwide_t::decwide_t_elems_for_fft; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + + template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_max_exp10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_min_exp10; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_max_exp; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) + template constexpr typename decwide_t::exponent_type decwide_t::decwide_t_min_exp; // NOLINT(readability-redundant-declaration,hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) #if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS) - template + template const typename decwide_t::initializer decwide_t::my_initializer; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix) #endif #if !defined(WIDE_DECIMAL_DISABLE_DYNAMIC_MEMORY_ALLOCATION) #else - template std::array::limb_type, static_cast((decwide_t::decwide_t_elems_for_kara - 1) * 2)> decwide_t::my_school_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables) - template std::array::limb_type, static_cast(detail::a029750::a029750_as_constexpr (static_cast(static_cast(decwide_t::decwide_t_elems_for_fft - 1)) * 8UL))> decwide_t::my_kara_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) - template std::array::fft_float_type, static_cast(detail::a000079::a000079_as_constexpr(static_cast(static_cast(decwide_t::decwide_t_elem_number)) * 4UL))> decwide_t::my_af_fft_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) - template std::array::fft_float_type, static_cast(detail::a000079::a000079_as_constexpr(static_cast(static_cast(decwide_t::decwide_t_elem_number)) * 4UL))> decwide_t::my_bf_fft_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) - template typename decwide_t::representation_type decwide_t::my_n_data_for_add_sub; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) + template std::array::limb_type, static_cast((decwide_t::decwide_t_elems_for_kara - 1) * 2)> decwide_t::my_school_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables) + template std::array::limb_type, static_cast(detail::a029750::a029750_as_constexpr (static_cast(static_cast(decwide_t::decwide_t_elems_for_fft - 1)) * 8UL))> decwide_t::my_kara_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) + template std::array::fft_float_type, static_cast(detail::a000079::a000079_as_constexpr(static_cast(static_cast(decwide_t::decwide_t_elem_number)) * 4UL))> decwide_t::my_af_fft_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) + template std::array::fft_float_type, static_cast(detail::a000079::a000079_as_constexpr(static_cast(static_cast(decwide_t::decwide_t_elem_number)) * 4UL))> decwide_t::my_bf_fft_mul_pool; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) + template typename decwide_t::representation_type decwide_t::my_n_data_for_add_sub; // NOLINT(hicpp-uppercase-literal-suffix,readability-uppercase-literal-suffix,cppcoreguidelines-avoid-non-const-global-variables,cert-err58-cpp) #endif #if !defined(WIDE_DECIMAL_DISABLE_IOSTREAM) - template + template auto decwide_t::wr_string(const decwide_t& x, // NOLINT(readability-function-cognitive-complexity) std::string& str, // NOLINT(google-runtime-references) std::ios::fmtflags ostrm_flags, @@ -4558,7 +4558,7 @@ } #endif - template + template auto calc_ln_two() -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT8_C(51))), decwide_t>::type { using local_wide_decimal_type = decwide_t; @@ -4928,7 +4928,7 @@ / m; } - template + template auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type { // N[Log[2], 121] @@ -4955,7 +4955,7 @@ ); } - template + template auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type { // N[Log[2], 121] @@ -4982,7 +4982,7 @@ ); } - template + template auto calc_ln_two() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type { // N[Log[2], 121] @@ -5009,7 +5009,7 @@ ); } - template + template auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type { // N[Log[10], 121] @@ -5035,7 +5035,7 @@ ); } - template + template auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type { // N[Log[10], 121] @@ -5061,7 +5061,7 @@ ); } - template + template auto calc_ln_ten_low_precision() -> typename std::enable_if<((ParamDigitsBaseTen <= static_cast(INT8_C(51))) && std::is_same::value), decwide_t>::type { // N[Log[10], 121] @@ -5088,7 +5088,7 @@ } #if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS) - template + template #if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION) auto pi(const std::function& pfn_callback_to_report_digits10) -> const decwide_t& #else @@ -5100,7 +5100,7 @@ return decwide_t::my_value_pi(); } #else - template + template #if !defined(WIDE_DECIMAL_DISABLE_USE_STD_FUNCTION) auto pi(const std::function& pfn_callback_to_report_digits10) -> decwide_t #else @@ -5112,14 +5112,14 @@ #endif #if !defined(WIDE_DECIMAL_DISABLE_CACHED_CONSTANTS) - template + template auto ln_two() -> const decwide_t& { return decwide_t::my_value_ln_two(); } #else // LCOV_EXCL_START - template + template auto ln_two() -> decwide_t { return calc_ln_two(); @@ -5128,17 +5128,17 @@ #endif // Global unary operators of decwide_t reference. - template auto operator+(const decwide_t& self) -> decwide_t { return self; } - template auto operator-(const decwide_t& self) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(self).negate(); } + template auto operator+(const decwide_t& self) -> decwide_t { return self; } + template auto operator-(const decwide_t& self) -> decwide_t { using local_wide_decimal_type = decwide_t; local_wide_decimal_type result { self }; result.negate(); return result; } // Global add/sub/mul/div of const decwide_t& with const decwide_t&. - templateauto operator+(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) += v; } - templateauto operator-(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) -= v; } - templateauto operator*(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) *= v; } - templateauto operator/(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) /= v; } + templateauto operator+(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) += v; } + templateauto operator-(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) -= v; } + templateauto operator*(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) *= v; } + templateauto operator/(const decwide_t& u, const decwide_t& v) -> decwide_t { using local_wide_decimal_type = decwide_t; return local_wide_decimal_type(u) /= v; } // Global add/sub/mul/div of const decwide_t& with all built-in types. - template + template auto operator+(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5149,7 +5149,7 @@ return local_wide_decimal_type(u).add_signed_long_long(n); } - template + template auto operator+(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5160,7 +5160,7 @@ return local_wide_decimal_type(u).add_unsigned_long_long(n); } - template + template auto operator+(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5170,7 +5170,7 @@ return local_wide_decimal_type(u) += decwide_t(f); } - template + template auto operator-(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5181,7 +5181,7 @@ return local_wide_decimal_type(u).sub_signed_long_long(n); } - template + template auto operator-(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5193,7 +5193,7 @@ } // LCOV_EXCL_START - template + template auto operator-(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5204,7 +5204,7 @@ } // LCOV_EXCL_STOP - template + template auto operator*(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5215,7 +5215,7 @@ return local_wide_decimal_type(u).mul_signed_long_long(n); } - template + template auto operator*(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5226,7 +5226,7 @@ return local_wide_decimal_type(u).mul_unsigned_long_long(n); } - template + template auto operator*(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5236,7 +5236,7 @@ return local_wide_decimal_type(u) *= decwide_t(f); } - template + template auto operator/(const decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5247,7 +5247,7 @@ return local_wide_decimal_type(u).div_signed_long_long(n); } - template + template auto operator/(const decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5258,7 +5258,7 @@ return local_wide_decimal_type(u).div_unsigned_long_long(n); } - template + template auto operator/(const decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5269,7 +5269,7 @@ } // Global add/sub/mul/div of all built-in types with const decwide_t&. - template + template auto operator+(SignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5280,7 +5280,7 @@ return local_wide_decimal_type(u).add_signed_long_long(n); } - template + template auto operator+(UnsignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5291,7 +5291,7 @@ return local_wide_decimal_type(u).add_unsigned_long_long(n); } - template + template auto operator+(FloatingPointType f, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type @@ -5301,7 +5301,7 @@ return local_wide_decimal_type(f) += u; } - template + template auto operator-(ArithmeticType n, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type @@ -5311,7 +5311,7 @@ return local_wide_decimal_type(n) -= u; } - template + template auto operator*(SignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5322,7 +5322,7 @@ return local_wide_decimal_type(u).mul_signed_long_long(n); } - template + template auto operator*(UnsignedIntegralType n, const decwide_t& u) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5333,7 +5333,7 @@ return local_wide_decimal_type(u).mul_unsigned_long_long(n); } - template + template auto operator*(FloatingPointType f, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type @@ -5343,7 +5343,7 @@ return local_wide_decimal_type(f) *= u; } - template + template auto operator/(ArithmeticType n, const decwide_t& u) -> typename std::enable_if::value, decwide_t>::type @@ -5354,7 +5354,7 @@ } // Global self add/sub/mul/div of decwide_t& with all built-in types. - template + template auto operator+=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5364,7 +5364,7 @@ } // LCOV_EXCL_START - template + template auto operator+=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5373,7 +5373,7 @@ return u.add_unsigned_long_long(n); } - template + template auto operator+=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5383,7 +5383,7 @@ return u += local_wide_decimal_type(f); } - template + template auto operator-=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5392,7 +5392,7 @@ return u.sub_signed_long_long(n); } - template + template auto operator-=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5401,7 +5401,7 @@ return u.sub_unsigned_long_long(n); } - template + template auto operator-=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5411,7 +5411,7 @@ return u -= local_wide_decimal_type(f); } - template + template auto operator*=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5420,7 +5420,7 @@ return u.mul_signed_long_long(n); } - template + template auto operator*=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5429,7 +5429,7 @@ return u.mul_unsigned_long_long(n); } - template + template auto operator*=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5440,7 +5440,7 @@ } // LCOV_EXCL_STOP - template + template auto operator/=(decwide_t& u, SignedIntegralType n) -> typename std::enable_if< std::is_integral::value && (!std::is_unsigned::value), @@ -5449,7 +5449,7 @@ return u.div_signed_long_long(n); } - template + template auto operator/=(decwide_t& u, UnsignedIntegralType n) -> typename std::enable_if< std::is_integral::value && std::is_unsigned::value, @@ -5458,7 +5458,7 @@ return u.div_unsigned_long_long(n); } - template + template auto operator/=(decwide_t& u, FloatingPointType f) -> typename std::enable_if::value, decwide_t>::type @@ -5469,28 +5469,28 @@ } // Global comparison operators of const decwide_t& with const decwide_t&. - template auto operator< (const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) < static_cast(INT8_C(0))); } - template auto operator<=(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) <= static_cast(INT8_C(0))); } - template auto operator==(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) == static_cast(INT8_C(0))); } - template auto operator!=(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) != static_cast(INT8_C(0))); } - template auto operator>=(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) >= static_cast(INT8_C(0))); } - template auto operator> (const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) > static_cast(INT8_C(0))); } + template auto operator< (const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) < static_cast(INT8_C(0))); } + template auto operator<=(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) <= static_cast(INT8_C(0))); } + template auto operator==(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) == static_cast(INT8_C(0))); } + template auto operator!=(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) != static_cast(INT8_C(0))); } + template auto operator>=(const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) >= static_cast(INT8_C(0))); } + template auto operator> (const decwide_t& u, const decwide_t& v) -> bool { return (u.cmp(v) > static_cast(INT8_C(0))); } // Global comparison operators of const decwide_t& with all built-in types. - template auto operator< (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) < static_cast(INT8_C(0))); } - template auto operator<=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) <= static_cast(INT8_C(0))); } - template auto operator==(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) == static_cast(INT8_C(0))); } - template auto operator!=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) != static_cast(INT8_C(0))); } - template auto operator>=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) >= static_cast(INT8_C(0))); } - template auto operator> (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) > static_cast(INT8_C(0))); } + template auto operator< (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) < static_cast(INT8_C(0))); } + template auto operator<=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) <= static_cast(INT8_C(0))); } + template auto operator==(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) == static_cast(INT8_C(0))); } + template auto operator!=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) != static_cast(INT8_C(0))); } + template auto operator>=(const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) >= static_cast(INT8_C(0))); } + template auto operator> (const decwide_t& u, const ArithmeticType& v) -> typename std::enable_if::value, bool>::type { return (u.cmp(decwide_t(v)) > static_cast(INT8_C(0))); } // Global comparison operators of all built-in types with const decwide_t&. - template auto operator< (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) < static_cast(INT8_C(0))); } - template auto operator<=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) <= static_cast(INT8_C(0))); } - template auto operator==(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) == static_cast(INT8_C(0))); } - template auto operator!=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) != static_cast(INT8_C(0))); } - template auto operator>=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) >= static_cast(INT8_C(0))); } - template auto operator> (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) > static_cast(INT8_C(0))); } + template auto operator< (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) < static_cast(INT8_C(0))); } + template auto operator<=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) <= static_cast(INT8_C(0))); } + template auto operator==(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) == static_cast(INT8_C(0))); } + template auto operator!=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) != static_cast(INT8_C(0))); } + template auto operator>=(ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) >= static_cast(INT8_C(0))); } + template auto operator> (ArithmeticType u, const decwide_t& v) -> typename std::enable_if::value, bool>::type { return (decwide_t(u).cmp(v) > static_cast(INT8_C(0))); } #if(__cplusplus >= 201703L) } // namespace math::wide_decimal @@ -5513,7 +5513,7 @@ #endif } // namespace nonstd - template local_wide_decimal_type { return local_wide_decimal_type::my_value_min(); } static constexpr auto (max) () -> local_wide_decimal_type { return local_wide_decimal_type::my_value_max(); } - static constexpr auto lowest () -> local_wide_decimal_type { return local_wide_decimal_type(); } + static constexpr auto lowest () -> local_wide_decimal_type { return -(max)(); } static constexpr auto epsilon() -> local_wide_decimal_type { return local_wide_decimal_type::from_lst @@ -5599,18 +5599,18 @@ namespace math { namespace wide_decimal { // NOLINT(modernize-concat-nested-namespaces) #endif - template constexpr auto unsigned_long_long_max() -> decwide_t { return decwide_t((std::numeric_limits::max)()); } // NOLINT(google-runtime-int) - template constexpr auto signed_long_long_min () -> decwide_t { return decwide_t((std::numeric_limits::min)()); } // NOLINT(google-runtime-int) - template constexpr auto signed_long_long_max () -> decwide_t { return decwide_t((std::numeric_limits::max)()); } // NOLINT(google-runtime-int) - template constexpr auto long_double_min () -> decwide_t { return decwide_t((std::numeric_limits::min)());} - template constexpr auto long_double_max () -> decwide_t { return decwide_t((std::numeric_limits::max)());} + template constexpr auto unsigned_long_long_max() -> decwide_t { return decwide_t((std::numeric_limits::max)()); } // NOLINT(google-runtime-int) + template constexpr auto signed_long_long_min () -> decwide_t { return decwide_t((std::numeric_limits::min)()); } // NOLINT(google-runtime-int) + template constexpr auto signed_long_long_max () -> decwide_t { return decwide_t((std::numeric_limits::max)()); } // NOLINT(google-runtime-int) + template constexpr auto long_double_min () -> decwide_t { return decwide_t((std::numeric_limits::min)());} + template constexpr auto long_double_max () -> decwide_t { return decwide_t((std::numeric_limits::max)());} - template auto (isnan) (const decwide_t& x) -> bool { return (x.isnan)(); } - template auto (isfinite)(const decwide_t& x) -> bool { return (x.isfinite)(); } - template auto (isinf) (const decwide_t& x) -> bool { return (x.isinf)(); } - template auto (signbit) (const decwide_t& x) -> bool { return x.isneg(); } + template auto (isnan) (const decwide_t& x) -> bool { return (x.isnan)(); } + template auto (isfinite)(const decwide_t& x) -> bool { return (x.isfinite)(); } + template auto (isinf) (const decwide_t& x) -> bool { return (x.isinf)(); } + template auto (signbit) (const decwide_t& x) -> bool { return x.isneg(); } - template + template auto pow(const decwide_t& x, const decwide_t& a) -> decwide_t { @@ -5619,7 +5619,7 @@ : exp(a * log(x)); } - template + template auto ldexp(const decwide_t& v, int e) -> decwide_t { if(e == static_cast(INT8_C(0))) @@ -5642,7 +5642,7 @@ } } - template + template auto frexp(const decwide_t& v, int* expon) -> decwide_t { @@ -5660,7 +5660,7 @@ return result; } - template + template auto fmod(const decwide_t& v1, const decwide_t& v2) -> decwide_t { @@ -5671,7 +5671,7 @@ return v1 - (nv * v2); } - template + template auto sqrt(const decwide_t& x) -> decwide_t { using local_wide_decimal_type = decwide_t; @@ -5679,13 +5679,13 @@ return local_wide_decimal_type(x).calculate_sqrt(); } - template + template auto cbrt(const decwide_t& x) -> decwide_t { return rootn(x, static_cast(3)); } - template + template auto rootn(const decwide_t& x, std::int32_t p) -> decwide_t // NOLINT(misc-no-recursion) { using local_wide_decimal_type = decwide_t; @@ -5725,7 +5725,7 @@ return rtn; } - template + template auto rootn_inv(const decwide_t& x, std::int32_t p) -> decwide_t { @@ -5734,7 +5734,7 @@ return local_wide_decimal_type(x).calculate_rootn_inv(p); } - template + template auto log(const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT8_C(51))), decwide_t>::type // NOLINT(misc-no-recursion) { using local_wide_decimal_type = decwide_t; @@ -5890,7 +5890,7 @@ return result; } - template + template auto log(const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast(INT8_C(51))), decwide_t>::type // NOLINT(misc-no-recursion) { using local_wide_decimal_type = decwide_t; @@ -6004,7 +6004,7 @@ return result; } - template + template auto exp(const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen > static_cast(INT32_C(2000))), decwide_t>::type { using local_wide_decimal_type = decwide_t; @@ -6100,7 +6100,7 @@ return exp_result; } - template + template auto exp(const decwide_t& x) -> typename std::enable_if<(ParamDigitsBaseTen <= static_cast(INT32_C(2000))), decwide_t>::type { using local_wide_decimal_type = decwide_t; @@ -6219,7 +6219,7 @@ return exp_result; } - template + template auto sinh(const decwide_t& x) -> decwide_t { const auto ep = exp(x); @@ -6229,7 +6229,7 @@ return (ep - local_wide_decimal_type(ep).calculate_inv()) /= static_cast(UINT8_C(2)); } - template + template auto cosh(const decwide_t& x) -> decwide_t { const auto ep = exp(x); @@ -6239,7 +6239,7 @@ return (ep + local_wide_decimal_type(ep).calculate_inv()) /= static_cast(UINT8_C(2)); } - template + template auto tanh(const decwide_t& x) -> decwide_t { const auto ep = exp(x); @@ -6251,7 +6251,7 @@ return (ep - em) /= (ep + em); } - template + template auto pow(const decwide_t& b, std::int64_t p) -> decwide_t // NOLINT(misc-no-recursion) { // Calculate (b ^ p). diff --git a/ref_app/src/math/wide_integer/uintwide_t.h b/ref_app/src/math/wide_integer/uintwide_t.h index 7bbeb89cf..255906155 100644 --- a/ref_app/src/math/wide_integer/uintwide_t.h +++ b/ref_app/src/math/wide_integer/uintwide_t.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 1999 - 2024. // +// Copyright Christopher Kormanyos 1999 - 2025. // // Distributed under the Boost Software License, // // Version 1.0. (See accompanying file LICENSE_1_0.txt // // or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -59,7 +59,7 @@ #endif #if (defined(_MSC_VER) && (!defined(__GNUC__) && !defined(__clang__))) - #if (_MSC_VER >= 1900) && defined(_HAS_CXX20) && (_HAS_CXX20 != 0) + #if ((_MSC_VER >= 1900) && (defined(_HAS_CXX20) && (_HAS_CXX20 != 0))) #define WIDE_INTEGER_NODISCARD [[nodiscard]] // NOLINT(cppcoreguidelines-macro-usage) #else #define WIDE_INTEGER_NODISCARD @@ -97,11 +97,11 @@ namespace iterator_detail { - class input_iterator_tag {}; - class output_iterator_tag {}; - class forward_iterator_tag : public input_iterator_tag {}; - class bidirectional_iterator_tag : public forward_iterator_tag {}; - class random_access_iterator_tag : public bidirectional_iterator_tag {}; + class input_iterator_tag { }; + class output_iterator_tag { }; + class forward_iterator_tag : public input_iterator_tag { }; + class bidirectional_iterator_tag : public forward_iterator_tag { }; + class random_access_iterator_tag : public bidirectional_iterator_tag { }; template class iterator_traits @@ -118,7 +118,7 @@ class iterator_traits { public: - using difference_type = std::ptrdiff_t; + using difference_type = ::std::ptrdiff_t; using value_type = T; using pointer = value_type*; using reference = value_type&; @@ -129,7 +129,7 @@ class iterator_traits { public: - using difference_type = std::ptrdiff_t; + using difference_type = ::std::ptrdiff_t; using value_type = T; using pointer = const value_type*; using reference = const value_type&; @@ -138,7 +138,7 @@ template struct my_iterator @@ -166,7 +166,7 @@ using reference = typename iterator_traits::reference; using iterator_category = typename iterator_traits::iterator_category; - constexpr reverse_iterator() = default; + constexpr reverse_iterator() { } // NOLINT(hicpp-use-equals-default,modernize-use-equals-default) explicit constexpr reverse_iterator(iterator_type x) : current(x) { } @@ -218,7 +218,7 @@ // Forward declaration of: // Use a local, constexpr, unsafe implementation of the abs-function. template - constexpr auto abs_unsafe(ArithmeticType val) -> ArithmeticType; + constexpr auto abs_unsafe(const ArithmeticType& val) -> ArithmeticType; // Use a local, constexpr, unsafe implementation of the fill-function. template(*first++); + #if (defined(__GNUC__) && (__GNUC__ > 9)) #pragma GCC diagnostic pop #pragma GCC diagnostic pop @@ -289,10 +291,10 @@ template constexpr auto swap_unsafe(T& left, T& right) noexcept -> void { - auto tmp = static_cast(left); + T tmp { std::move(static_cast(left)) }; - left = static_cast(right); - right = static_cast(tmp); + left = std::move(static_cast(right)); + right = std::move(static_cast(tmp)); } template @@ -385,13 +387,10 @@ { while(first1 != last1) { - if(!(*first1 == *first2)) + if(!(*first1++ == *first2++)) { return false; } - - ++first1; - ++first2; } return true; @@ -402,7 +401,7 @@ { while((first1 != last1) && (first2 != last2)) { - if(*first1 < *first2) + if(*first1++ < *first2++) { return true; } @@ -411,9 +410,6 @@ { return false; } - - ++first1; - ++first2; } return ((first1 == last1) && (first2 != last2)); @@ -447,9 +443,9 @@ { using local_unsigned_integral_type = UnsignedIntegralType; - auto yy_val = static_cast(UINT8_C(0)); + local_unsigned_integral_type yy_val { local_unsigned_integral_type { UINT8_C(0) } }; - auto nn_val = static_cast(std::numeric_limits::digits); + unsigned nn_val { static_cast(std::numeric_limits::digits) }; auto cc_val = // NOLINT(altera-id-dependent-backward-branch) static_cast @@ -509,9 +505,9 @@ if(v == static_cast(UINT8_C(0))) { return u; } // Shift the greatest power of 2 dividing both u and v. - const auto trz = static_cast(ctz_unsafe(u)); + const unsigned trz { static_cast(ctz_unsafe(u)) }; - const auto shift_amount = (detail::min_unsafe)(trz, ctz_unsafe(v)); + const unsigned shift_amount { detail::min_unsafe(trz, ctz_unsafe(v)) }; v >>= shift_amount; u >>= trz; @@ -536,13 +532,13 @@ namespace array_detail { - template + template class array { public: // Standard container-local type definitions. - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; + using size_type = ::std::size_t; + using difference_type = ::std::ptrdiff_t; using value_type = T; using pointer = T*; using const_pointer = const T*; @@ -669,15 +665,15 @@ template class tuple_size; - template + template class tuple_size> : public std::integral_constant { }; - template + template class tuple_element; - template + const ::std::size_t N> class tuple_element > { static_assert(I < N, "Sorry, tuple_element index is out of bounds."); @@ -704,9 +700,9 @@ namespace util { template, - typename SizeType = std::size_t, - typename DiffType = std::ptrdiff_t> + typename AllocatorType = ::std::allocator, + typename SizeType = ::std::size_t, + typename DiffType = ::std::ptrdiff_t> class dynamic_array; template static_cast(UINT8_C(0))) @@ -779,8 +775,8 @@ template constexpr dynamic_array(input_iterator first, - input_iterator last, - const allocator_type& alloc_in = allocator_type()) + input_iterator last, + const allocator_type& alloc_in = allocator_type()) : elem_count(static_cast(last - first)) { allocator_type my_alloc(alloc_in); @@ -799,7 +795,7 @@ } constexpr dynamic_array(std::initializer_list lst, - const allocator_type& alloc_in = allocator_type()) + const allocator_type& alloc_in = allocator_type()) : elem_count(lst.size()) { allocator_type my_alloc(alloc_in); @@ -818,7 +814,7 @@ // Move constructor. constexpr dynamic_array(dynamic_array&& other) noexcept : elem_count(other.elem_count), - elems (other.elems) + elems (other.elems) { other.elem_count = static_cast(UINT8_C(0)); other.elems = nullptr; @@ -943,10 +939,10 @@ constexpr auto swap(dynamic_array&& other) noexcept -> void { - const auto tmp = std::move(*this); + dynamic_array tmp { std::move(*this) }; - *this = std::move(other); - other = std::move(tmp); + *this = std::move(static_cast(other)); + other = std::move(static_cast(tmp)); } private: @@ -972,7 +968,7 @@ template constexpr auto operator<(const dynamic_array& lhs, - const dynamic_array& rhs) -> bool + const dynamic_array& rhs) -> bool { using size_type = typename dynamic_array::size_type; @@ -1106,8 +1102,8 @@ using size_t = std::uint32_t; using ptrdiff_t = std::int32_t; - static_assert(( (std::numeric_limits::digits >= std::numeric_limits::digits) - && (std::numeric_limits::digits + 1 >= std::numeric_limits::digits)), + static_assert(( (std::numeric_limits::digits >= std::numeric_limits::digits) + && (std::numeric_limits::digits + 1 >= std::numeric_limits::digits)), "Error: size type and pointer difference type must be at least 16 bits in width (or wider)"); template struct verify_power_of_two // NOLINT(altera-struct-pack-align) @@ -2090,7 +2086,7 @@ template + const bool RePhraseIsSigned> friend class uintwide_t; // Class-local type definitions. @@ -2109,11 +2105,11 @@ static_assert(((sizeof(limb_type) * 2U) == sizeof(double_limb_type)), "Error: Please check the characteristics of the template parameters UnsignedShortType and UnsignedLargeType"); #else - static_assert(( ( std::numeric_limits::is_integer) - && ( std::numeric_limits::is_integer) - && (!std::numeric_limits::is_signed) - && (!std::numeric_limits::is_signed) - && ((sizeof(limb_type) * 2U) == sizeof(double_limb_type))), + static_assert(( ( std::numeric_limits::is_integer) + && ( std::numeric_limits::is_integer) + && (!std::numeric_limits::is_signed) + && (!std::numeric_limits::is_signed) + && ((sizeof(limb_type) * 2U) == sizeof(double_limb_type))), "Error: Please check the characteristics of the template parameters UnsignedShortType and UnsignedLargeType"); #endif @@ -2308,19 +2304,19 @@ #endif // Copy-like constructor from the other signed-ness type. - template const* = nullptr> - constexpr uintwide_t(const uintwide_t& other) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + template const* = nullptr> + constexpr uintwide_t(const uintwide_t& other) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) : values(other.values) { } // Copy-like constructor from the another type having width that is wider // (but has the same limb type) and possibly a different signed-ness. template const* = nullptr> - explicit constexpr uintwide_t(const uintwide_t& v) + explicit constexpr uintwide_t(const uintwide_t& v) { - using other_wide_integer_type = uintwide_t; + using other_wide_integer_type = uintwide_t; const auto v_is_neg = (other_wide_integer_type::is_neg(v)); @@ -2347,11 +2343,11 @@ // Copy-like constructor from the another type having width that is less wide // (but has the same limb type) and possibly a different signed-ness. template OtherWidth2)> const* = nullptr> - explicit constexpr uintwide_t(const uintwide_t& v) + explicit constexpr uintwide_t(const uintwide_t& v) { - using other_wide_integer_type = uintwide_t; + using other_wide_integer_type = uintwide_t; constexpr auto sz = static_cast(other_wide_integer_type::number_of_limbs); @@ -2397,18 +2393,18 @@ // Move-like constructor from the other signed-ness type. // This constructor is non-explicit because it is a trivial conversion. - template const* = nullptr> - constexpr uintwide_t(uintwide_t&& other) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) + template const* = nullptr> + constexpr uintwide_t(uintwide_t&& other) // NOLINT(google-explicit-constructor,hicpp-explicit-conversions) : values(static_cast(other.values)) { } // Assignment operator. constexpr auto operator=(const uintwide_t&) -> uintwide_t& = default; // LCOV_EXCL_LINE // Assignment operator from the other signed-ness type. - template const* = nullptr> - constexpr auto operator=(const uintwide_t& other) -> uintwide_t& + template const* = nullptr> + constexpr auto operator=(const uintwide_t& other) -> uintwide_t& { values = other.values; @@ -2419,9 +2415,9 @@ constexpr auto operator=(uintwide_t&& other) noexcept -> uintwide_t& = default; // LCOV_EXCL_LINE // Trivial move assignment operator from the other signed-ness type. - template const* = nullptr> - constexpr auto operator=(uintwide_t&& other) -> uintwide_t& + template const* = nullptr> + constexpr auto operator=(uintwide_t&& other) -> uintwide_t& { values = static_cast(other.values); @@ -2454,12 +2450,12 @@ // Cast operator that casts to a uintwide_t possibly having a different width // and/or possibly having a different signed-ness, but having the same limb type. template - constexpr operator uintwide_t() const // NOLINT(hicpp-explicit-conversions,google-explicit-constructor) + const bool RePhraseIsSigned> + constexpr operator uintwide_t() const // NOLINT(hicpp-explicit-conversions,google-explicit-constructor) { const auto this_is_neg = is_neg(*this); - using other_wide_integer_type = uintwide_t; + using other_wide_integer_type = uintwide_t; constexpr auto sz = static_cast @@ -2862,8 +2858,8 @@ constexpr auto operator>=(const uintwide_t& other) const -> bool { return (compare(other) >= static_cast( 0)); } // Helper functions for supporting std::numeric_limits<>. - template - static constexpr auto limits_helper_max() -> std::enable_if_t<(!OtherIsSigned), uintwide_t> + template + static constexpr auto limits_helper_max() -> std::enable_if_t<(!RePhraseIsSigned), uintwide_t> { uintwide_t result_max { }; @@ -2872,8 +2868,8 @@ return result_max; } - template - static constexpr auto limits_helper_max() -> std::enable_if_t + template + static constexpr auto limits_helper_max() -> std::enable_if_t { uintwide_t result_max { }; @@ -2890,14 +2886,14 @@ return result_max; } - template - static constexpr auto limits_helper_min() -> std::enable_if_t<(!OtherIsSigned), uintwide_t> + template + static constexpr auto limits_helper_min() -> std::enable_if_t<(!RePhraseIsSigned), uintwide_t> { return uintwide_t { }; } - template - static constexpr auto limits_helper_min() -> std::enable_if_t + template + static constexpr auto limits_helper_min() -> std::enable_if_t { uintwide_t result_min { }; @@ -3223,15 +3219,15 @@ auto hi_part = static_cast(UINT8_C(0)); { - auto ri = - static_cast - ( + reverse_iterator + ri + { detail::advance_and_point ( values.begin(), static_cast(number_of_limbs - static_cast(u_offset)) ) - ); + }; for( ; ri != values.rend(); ++ri) // NOLINT(altera-id-dependent-backward-branch) { @@ -3262,10 +3258,21 @@ static_cast ( static_cast(*values.cbegin()) - + static_cast(static_cast(long_numerator - static_cast(static_cast(short_denominator) * hi_part)) << static_cast(std::numeric_limits::digits)) + + static_cast + ( + static_cast + ( + long_numerator - static_cast(static_cast(short_denominator) * hi_part) + ) + << static_cast(std::numeric_limits::digits) + ) ); - *remainder = static_cast(long_numerator >> static_cast(std::numeric_limits::digits)); + *remainder = + static_cast + ( + long_numerator >> static_cast(std::numeric_limits::digits) + ); } } @@ -3289,11 +3296,9 @@ } template - static constexpr auto is_neg(const uintwide_t& a, - std::enable_if_t* p_nullparam = nullptr) -> bool + static constexpr auto is_neg(const uintwide_t& a, // NOLINT(hicpp-named-parameter,readability-named-parameter) + std::enable_if_t* = nullptr) -> bool // NOLINT(hicpp-named-parameter,readability-named-parameter) { - static_cast(p_nullparam); - return (static_cast(static_cast(a.values.back() >> static_cast(std::numeric_limits::limb_type>::digits - 1)) & 1U) != 0U); } @@ -3470,10 +3475,10 @@ template + const bool RePhraseIsSigned> friend constexpr auto from_chars(const char* first, // NOLINT(readability-redundant-declaration) const char* last, - uintwide_t& x, + uintwide_t& x, int base) -> std::from_chars_result; #endif @@ -4963,7 +4968,7 @@ for(auto t = static_cast(u_j_j1 - static_cast(q_hat * static_cast(vv_at_vj0))); ; - --q_hat, t = static_cast(t + vv_at_vj0)) + t = static_cast(t + vv_at_vj0), --q_hat) { if( (detail::make_hi(t) != static_cast(UINT8_C(0))) || ( static_cast(static_cast(vv_at_vj0_minus_one) * q_hat) @@ -5516,7 +5521,7 @@ static constexpr auto (max) () -> local_wide_integer_type { return local_wide_integer_type::template limits_helper_max(); } static constexpr auto (min) () -> local_wide_integer_type { return local_wide_integer_type::template limits_helper_min(); } - static constexpr auto lowest() -> local_wide_integer_type { return local_wide_integer_type::template limits_helper_min(); } + static constexpr auto lowest() -> local_wide_integer_type { return (min)(); } }; template @@ -6608,7 +6613,7 @@ // Use a local, constexpr, unsafe implementation of the abs-function. template - constexpr auto abs_unsafe(ArithmeticType val) -> ArithmeticType + constexpr auto abs_unsafe(const ArithmeticType& val) -> ArithmeticType { if(val > static_cast(INT8_C(0))) { @@ -6616,7 +6621,7 @@ } else // NOLINT(llvm-else-after-return,readability-else-after-return) { - ArithmeticType val_unsigned = std::move(val); + ArithmeticType val_unsigned { val }; val_unsigned.negate(); @@ -6869,8 +6874,8 @@ template::digits> - constexpr auto operator()( GeneratorType& input_generator, - const param_type& input_params) -> result_type + constexpr auto operator()(GeneratorType& input_generator, + const param_type& input_params) -> result_type { return generate @@ -6885,8 +6890,8 @@ template::digits> - constexpr auto generate( GeneratorType& input_generator, - const param_type& input_params) const -> result_type + constexpr auto generate(GeneratorType& input_generator, + const param_type& input_params) const -> result_type { // Generate random numbers r, where a <= r <= b. @@ -6994,7 +6999,7 @@ // This Miller-Rabin primality test is loosely based on // an adaptation of some code from Boost.Multiprecision. // The Boost.Multiprecision code can be found here: - // https://www.boost.org/doc/libs/1_76_0/libs/multiprecision/doc/html/boost_multiprecision/tut/primetest.html + // https://www.boost.org/doc/libs/1_87_0/libs/multiprecision/doc/html/boost_multiprecision/tut/primetest.html // Note: Some comments in this subroutine use the Wolfram Language(TM). // These can be exercised at the web links to WolframAlpha(R) provided @@ -7131,10 +7136,10 @@ } } - const auto nm1 = static_cast(np - static_cast(UINT8_C(1))); + const local_wide_integer_type nm1 { np - static_cast(UINT8_C(1)) }; auto - isone + local_functor_isone { [](const local_wide_integer_type& t1) { @@ -7155,7 +7160,7 @@ const local_wide_integer_type fn { powm(local_wide_integer_type(static_cast(228U)), nm1, np) }; - if(!isone(fn)) + if(!local_functor_isone(fn)) { return false; } @@ -7174,45 +7179,39 @@ np - unsigned { UINT8_C(2) } }; - local_wide_integer_type x; - local_wide_integer_type y; - // Assume the test will pass, even though it usually does not pass. - bool result { true }; + bool result_candidate_is_prime { true }; - // Loop over the trials to perform the primality testing. + ::std::size_t idx { UINT8_C(0) }; + + using local_double_width_type = typename local_wide_integer_type::double_width_type; - std::size_t idx { UINT8_C(0) }; + const local_double_width_type np_dbl { np }; + // Loop over the trials to perform the primality testing. do { - x = distribution(generator, params); - y = powm(x, q, np); - - using local_double_width_type = typename local_wide_integer_type::double_width_type; + local_wide_integer_type y { powm(distribution(generator, params), q, np) }; - const local_double_width_type np_dbl { np }; - - std::size_t jdx { UINT8_C(0) }; + ::std::size_t jdx { UINT8_C(0) }; // Continue while y is not nm1, and while y is not 1, // and while the result is true. - while((y != nm1) && (!isone(y)) && result) // NOLINT(altera-id-dependent-backward-branch) + while((y != nm1) && (!local_functor_isone(y)) && result_candidate_is_prime) // NOLINT(altera-id-dependent-backward-branch) { ++jdx; if(jdx == static_cast(k)) { // Mark failure if max iterations reached. - result = false; + result_candidate_is_prime = false; } else { // Continue with the next value of y. - // Manually calculate: - // y = powm(y, 2, np); + // Manually calculate: y = powm(y, 2, np); local_double_width_type yd { y }; @@ -7224,17 +7223,17 @@ } // Check for (y == 1) after the loop. - if(isone(y) && (jdx != std::size_t { UINT8_C(0) })) + if(local_functor_isone(y) && (jdx != ::std::size_t { UINT8_C(0) })) { // Mark failure if (y == 1) and (jdx != 0). - result = false; + result_candidate_is_prime = false; } ++idx; } - while((idx < number_of_trials) && result); + while((idx < number_of_trials) && result_candidate_is_prime); - return result; + return result_candidate_is_prime; } #if (defined(__cpp_lib_to_chars) && (__cpp_lib_to_chars >= 201611L)) @@ -7242,11 +7241,10 @@ typename LimbType, typename AllocatorType, const bool IsSigned> - constexpr - auto to_chars(char* first, - char* last, - const uintwide_t& x, - int base) -> std::to_chars_result + constexpr auto to_chars(char* first, + char* last, + const uintwide_t& x, + int base) -> std::to_chars_result { using local_wide_integer_type = uintwide_t; @@ -7406,11 +7404,10 @@ typename LimbType, typename AllocatorType, const bool IsSigned> - constexpr - auto from_chars(const char* first, - const char* last, - uintwide_t& x, - int base) -> std::from_chars_result + constexpr auto from_chars(const char* first, + const char* last, + uintwide_t& x, + int base) -> std::from_chars_result { using local_wide_integer_type = uintwide_t; @@ -7550,7 +7547,7 @@ const auto chunk_is_whole = (chunk_size == static_cast(std::numeric_limits::digits)); - std::size_t input_distance { }; + ::std::size_t input_distance { }; { local_input_iterator_type non_const_first = first; @@ -7663,7 +7660,7 @@ static_assert(std::numeric_limits::digits != std::numeric_limits::digits, "Error: Erroneous match for input element width and result uintwide_t limb width"); - std::size_t input_distance { }; + ::std::size_t input_distance { }; { local_input_iterator_type non_const_first = first;