diff --git a/math/wide_decimal/decwide_t_detail.h b/math/wide_decimal/decwide_t_detail.h index d1aac0a..614357b 100644 --- a/math/wide_decimal/decwide_t_detail.h +++ b/math/wide_decimal/decwide_t_detail.h @@ -193,13 +193,13 @@ static_cast(UINT32_C(2097152)) }; - const std::uint32_t* it = util::lower_bound_unsafe(std::begin(a029750_data), std::end(a029750_data), value); + const auto* p_elem = util::lower_bound_unsafe(std::begin(a029750_data), std::end(a029750_data), value); const auto result = static_cast ( - (it != std::end(a029750_data)) - ? *it + (p_elem != std::end(a029750_data)) + ? *p_elem : *(std::end(a029750_data) - static_cast(UINT8_C(1))) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) ); @@ -241,7 +241,9 @@ constexpr auto pow10_maker_as_runtime_value(std::uint32_t n) noexcept -> std::uint32_t { - constexpr std::uint32_t local_p10_table[static_cast(UINT8_C(10))] = // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) + using local_p10_data_array_type = std::array(UINT8_C(10))>; + + constexpr local_p10_data_array_type local_p10_data = // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays) { static_cast(UINT32_C(1)), static_cast(UINT32_C(10)), @@ -255,12 +257,7 @@ static_cast(UINT32_C(1000000000)) }; - const std::uint32_t result = - ( - (n < static_cast(sizeof(local_p10_table) / sizeof(local_p10_table[static_cast(UINT8_C(0))]))) - ? local_p10_table[static_cast(n)] // NOLINT(cppcoreguidelines-pro-bounds-constant-array-index) - : *(std::end(local_p10_table) - static_cast(UINT8_C(1))) // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) - ); + const auto result = (static_cast(n) < std::tuple_size::value) ? local_p10_data[static_cast(n)] : local_p10_data.back(); return result; } diff --git a/soft_double.vcxproj b/soft_double.vcxproj index f20ecea..5150bcc 100644 --- a/soft_double.vcxproj +++ b/soft_double.vcxproj @@ -47,6 +47,8 @@ + + diff --git a/soft_double.vcxproj.filters b/soft_double.vcxproj.filters index 6c0c7e9..a1c69b1 100644 --- a/soft_double.vcxproj.filters +++ b/soft_double.vcxproj.filters @@ -167,6 +167,12 @@ util\utility + + util\utility + + + util\utility +