|
2611 | 2611 | }
|
2612 | 2612 | else if(other.is_zero())
|
2613 | 2613 | {
|
2614 |
| - *this = limits_helper_max(IsSigned); |
| 2614 | + static_cast<void>(operator=(limits_helper_max<IsSigned>())); |
2615 | 2615 | }
|
2616 | 2616 | else
|
2617 | 2617 | {
|
|
2709 | 2709 | {
|
2710 | 2710 | if(this != &other) // LCOV_EXCL_LINE
|
2711 | 2711 | {
|
2712 |
| - auto bi = other.values.cbegin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto) |
| 2712 | + auto itr_b = other.values.cbegin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto) |
2713 | 2713 |
|
2714 | 2714 | // Perform bitwise OR.
|
2715 |
| - for(auto& a : values) |
| 2715 | + for(auto itr_a = values.begin(); itr_a != values.end(); ++itr_a, ++itr_b) // NOLINT(altera-id-dependent-backward-branch,llvm-qualified-auto,readability-qualified-auto) |
2716 | 2716 | {
|
2717 |
| - a = static_cast<limb_type>(a | *bi); |
2718 |
| - |
2719 |
| - ++bi; |
| 2717 | + *itr_a = static_cast<limb_type>(*itr_a | *itr_b); |
2720 | 2718 | }
|
2721 | 2719 | }
|
2722 | 2720 |
|
|
2731 | 2729 | }
|
2732 | 2730 | else
|
2733 | 2731 | {
|
2734 |
| - auto bi = other.values.cbegin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto) |
| 2732 | + auto itr_b = other.values.cbegin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto) |
2735 | 2733 |
|
2736 | 2734 | // Perform bitwise XOR.
|
2737 |
| - for(auto& a : values) |
| 2735 | + for(auto itr_a = values.begin(); itr_a != values.end(); ++itr_a, ++itr_b) // NOLINT(altera-id-dependent-backward-branch,llvm-qualified-auto,readability-qualified-auto) |
2738 | 2736 | {
|
2739 |
| - a = static_cast<limb_type>(a ^ *bi); |
2740 |
| - |
2741 |
| - ++bi; |
| 2737 | + *itr_a = static_cast<limb_type>(*itr_a ^ *itr_b); |
2742 | 2738 | }
|
2743 | 2739 | }
|
2744 | 2740 |
|
|
2749 | 2745 | {
|
2750 | 2746 | if(this != &other) // LCOV_EXCL_LINE
|
2751 | 2747 | {
|
2752 |
| - auto bi = other.values.cbegin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto) |
| 2748 | + auto itr_b = other.values.cbegin(); // NOLINT(llvm-qualified-auto,readability-qualified-auto) |
2753 | 2749 |
|
2754 | 2750 | // Perform bitwise AND.
|
2755 |
| - for(auto& a : values) |
| 2751 | + for(auto itr_a = values.begin(); itr_a != values.end(); ++itr_a, ++itr_b) // NOLINT(altera-id-dependent-backward-branch,llvm-qualified-auto,readability-qualified-auto) |
2756 | 2752 | {
|
2757 |
| - a = static_cast<limb_type>(a & *bi); |
2758 |
| - |
2759 |
| - ++bi; |
| 2753 | + *itr_a = static_cast<limb_type>(*itr_a & *itr_b); |
2760 | 2754 | }
|
2761 | 2755 | }
|
2762 | 2756 |
|
|
2884 | 2878 | constexpr auto operator>=(const uintwide_t& other) const -> bool { return (compare(other) >= static_cast<std::int_fast8_t>( 0)); }
|
2885 | 2879 |
|
2886 | 2880 | // Helper functions for supporting std::numeric_limits<>.
|
2887 |
| - static constexpr auto limits_helper_max(bool is_signed) -> uintwide_t |
| 2881 | + template<const bool OtherIsSigned> |
| 2882 | + static constexpr auto limits_helper_max() -> std::enable_if_t<(!OtherIsSigned), uintwide_t> |
2888 | 2883 | {
|
2889 |
| - return |
2890 |
| - (!is_signed) |
2891 |
| - ? from_rep |
2892 |
| - ( |
2893 |
| - representation_type |
2894 |
| - ( |
2895 |
| - number_of_limbs, (std::numeric_limits<limb_type>::max)() |
2896 |
| - ) |
2897 |
| - ) |
2898 |
| - : from_rep |
2899 |
| - ( |
2900 |
| - representation_type |
2901 |
| - ( |
2902 |
| - number_of_limbs, (std::numeric_limits<limb_type>::max)() // LCOV_EXCL_LINE |
2903 |
| - ) |
2904 |
| - ) |
2905 |
| - ^ |
2906 |
| - ( |
2907 |
| - uintwide_t(static_cast<std::uint8_t>(UINT8_C(1))) |
2908 |
| - << static_cast<std::uint32_t>(my_width2 - static_cast<std::uint8_t>(UINT8_C(1))) |
2909 |
| - ) |
2910 |
| - ; |
| 2884 | + uintwide_t result_max { }; |
| 2885 | + |
| 2886 | + detail::fill_unsafe(result_max.values.begin(), result_max.values.end(), (std::numeric_limits<limb_type>::max)()); |
| 2887 | + |
| 2888 | + return result_max; |
2911 | 2889 | }
|
2912 | 2890 |
|
2913 |
| - static constexpr auto limits_helper_min(bool is_signed) -> uintwide_t |
| 2891 | + template<const bool OtherIsSigned> |
| 2892 | + static constexpr auto limits_helper_max() -> std::enable_if_t<OtherIsSigned, uintwide_t> |
2914 | 2893 | {
|
2915 |
| - return |
2916 |
| - (!is_signed) |
2917 |
| - ? from_rep |
2918 |
| - ( |
2919 |
| - representation_type |
2920 |
| - ( |
2921 |
| - number_of_limbs, static_cast<limb_type>(UINT8_C(0)) |
2922 |
| - ) |
2923 |
| - ) |
2924 |
| - : from_rep |
2925 |
| - ( |
2926 |
| - representation_type |
2927 |
| - ( |
2928 |
| - number_of_limbs, static_cast<limb_type>(UINT8_C(0)) // LCOV_EXCL_LINE |
2929 |
| - ) |
2930 |
| - ) |
2931 |
| - | |
2932 |
| - ( |
2933 |
| - uintwide_t(static_cast<std::uint8_t>(UINT8_C(1))) |
2934 |
| - << static_cast<std::uint32_t>(my_width2 - static_cast<std::uint8_t>(UINT8_C(1))) |
2935 |
| - ) |
2936 |
| - ; |
| 2894 | + uintwide_t result_max { }; |
| 2895 | + |
| 2896 | + detail::fill_unsafe(result_max.values.begin(), result_max.values.end(), (std::numeric_limits<limb_type>::max)()); |
| 2897 | + |
| 2898 | + constexpr auto high_bit_limb = |
| 2899 | + static_cast<limb_type> |
| 2900 | + ( |
| 2901 | + static_cast<limb_type>(UINT8_C(1)) << static_cast<unsigned>(std::numeric_limits<limb_type>::digits - static_cast<int>(INT8_C(1))) |
| 2902 | + ); |
| 2903 | + |
| 2904 | + result_max.values.back() ^= high_bit_limb; |
| 2905 | + |
| 2906 | + return result_max; |
2937 | 2907 | }
|
2938 | 2908 |
|
2939 |
| - static constexpr auto limits_helper_lowest(bool is_signed) -> uintwide_t |
| 2909 | + template<const bool OtherIsSigned> |
| 2910 | + static constexpr auto limits_helper_min() -> std::enable_if_t<(!OtherIsSigned), uintwide_t> |
2940 | 2911 | {
|
2941 |
| - return |
2942 |
| - (!is_signed) |
2943 |
| - ? from_rep |
2944 |
| - ( |
2945 |
| - representation_type |
2946 |
| - ( |
2947 |
| - number_of_limbs, static_cast<limb_type>(UINT8_C(0)) |
2948 |
| - ) |
2949 |
| - ) |
2950 |
| - : from_rep |
2951 |
| - ( |
2952 |
| - representation_type |
2953 |
| - ( |
2954 |
| - number_of_limbs, static_cast<limb_type>(UINT8_C(0)) |
2955 |
| - ) |
2956 |
| - ) |
2957 |
| - | |
2958 |
| - ( |
2959 |
| - uintwide_t(static_cast<std::uint8_t>(UINT8_C(1))) |
2960 |
| - << static_cast<std::uint32_t>(my_width2 - static_cast<std::uint8_t>(UINT8_C(1))) |
2961 |
| - ) |
2962 |
| - ; |
| 2912 | + return uintwide_t { }; |
| 2913 | + } |
| 2914 | + |
| 2915 | + template<const bool OtherIsSigned> |
| 2916 | + static constexpr auto limits_helper_min() -> std::enable_if_t<OtherIsSigned, uintwide_t> |
| 2917 | + { |
| 2918 | + uintwide_t result_min { }; |
| 2919 | + |
| 2920 | + constexpr auto high_bit_limb = |
| 2921 | + static_cast<limb_type> |
| 2922 | + ( |
| 2923 | + static_cast<limb_type>(UINT8_C(1)) << static_cast<unsigned>(std::numeric_limits<limb_type>::digits - static_cast<int>(INT8_C(1))) |
| 2924 | + ); |
| 2925 | + |
| 2926 | + result_min.values.back() |= high_bit_limb; |
| 2927 | + |
| 2928 | + return result_min; |
| 2929 | + } |
| 2930 | + |
| 2931 | + template<const bool OtherIsSigned> |
| 2932 | + static constexpr auto limits_helper_lowest() -> uintwide_t |
| 2933 | + { |
| 2934 | + return limits_helper_min<OtherIsSigned>(); |
2963 | 2935 | }
|
2964 | 2936 |
|
2965 | 2937 | // Write string function.
|
|
4531 | 4503 | );
|
4532 | 4504 |
|
4533 | 4505 | *r++ = static_cast<local_limb_type>(carry);
|
4534 |
| - carry = detail::make_hi<local_limb_type>(carry); |
| 4506 | + carry = static_cast<local_double_limb_type>(detail::make_hi<local_limb_type>(carry)); |
4535 | 4507 | }
|
4536 | 4508 |
|
4537 | 4509 | #if defined(WIDE_INTEGER_HAS_CLZ_LIMB_OPTIMIZATIONS)
|
4538 | 4510 | for( ; i < count; ++i)
|
4539 | 4511 | {
|
4540 | 4512 | *r++ = static_cast<local_limb_type>(carry);
|
4541 |
| - carry = detail::make_hi<local_limb_type>(static_cast<local_double_limb_type>(UINT8_C(0))); |
| 4513 | + carry = static_cast<local_double_limb_type>(UINT8_C(0)); |
4542 | 4514 | }
|
4543 | 4515 | #endif
|
4544 | 4516 | }
|
|
4798 | 4770 | {
|
4799 | 4771 | // The denominator is zero. Set the maximum value and return.
|
4800 | 4772 | // This also catches (0 / 0) and sets the maximum value for it.
|
4801 |
| - static_cast<void>(operator=(limits_helper_max(IsSigned))); // LCOV_EXCL_LINE |
| 4773 | + static_cast<void>(operator=(limits_helper_max<IsSigned>())); // LCOV_EXCL_LINE |
4802 | 4774 |
|
4803 | 4775 | if(remainder != nullptr) // LCOV_EXCL_LINE
|
4804 | 4776 | {
|
|
5535 | 5507 | static constexpr int max_exponent = digits;
|
5536 | 5508 | static constexpr int max_exponent10 = static_cast<int>((static_cast<std::uintmax_t>(max_exponent) * UINTMAX_C(75257499)) / UINTMAX_C(250000000));
|
5537 | 5509 |
|
5538 |
| - static constexpr auto (max) () -> local_wide_integer_type { return local_wide_integer_type::limits_helper_max (IsSigned); } |
5539 |
| - static constexpr auto (min) () -> local_wide_integer_type { return local_wide_integer_type::limits_helper_min (IsSigned); } |
5540 |
| - static constexpr auto lowest() -> local_wide_integer_type { return local_wide_integer_type::limits_helper_lowest(IsSigned); } |
| 5510 | + static constexpr auto (max) () -> local_wide_integer_type { return local_wide_integer_type::template limits_helper_max <IsSigned>(); } |
| 5511 | + static constexpr auto (min) () -> local_wide_integer_type { return local_wide_integer_type::template limits_helper_min <IsSigned>(); } |
| 5512 | + static constexpr auto lowest() -> local_wide_integer_type { return local_wide_integer_type::template limits_helper_lowest<IsSigned>(); } |
5541 | 5513 | };
|
5542 | 5514 |
|
5543 | 5515 | template<class T>
|
|
0 commit comments