@@ -39,7 +39,8 @@ namespace detail {
3939template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
4040constexpr auto from_chars_general_impl (const char * first, const char * last, TargetDecimalType& value, chars_format fmt) noexcept -> from_chars_result
4141{
42- using significand_type = std::conditional_t <std::is_same<TargetDecimalType, decimal128>::value, detail::uint128, std::uint64_t >;
42+ using significand_type = std::conditional_t <std::is_same<TargetDecimalType, decimal128>::value ||
43+ std::is_same<TargetDecimalType, decimal128_fast>::value, detail::uint128, std::uint64_t >;
4344
4445 if (first >= last)
4546 {
@@ -714,6 +715,11 @@ BOOST_DECIMAL_CONSTEXPR auto to_chars_hex_impl(char* first, char* last, const Ta
714715 return to_chars_integer_impl<std::uint32_t , std::uint32_t >(first, last, static_cast <std::uint32_t >(abs_exp), 10 );
715716}
716717
718+ #ifdef _MSC_VER
719+ # pragma warning(push)
720+ # pragma warning(disable: 4702) // Unreachable code
721+ #endif
722+
717723template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
718724BOOST_DECIMAL_CONSTEXPR auto to_chars_impl (char * first, char * last, TargetDecimalType value, chars_format fmt = chars_format::general, int precision = -1 ) noexcept -> to_chars_result
719725{
@@ -730,28 +736,26 @@ BOOST_DECIMAL_CONSTEXPR auto to_chars_impl(char* first, char* last, TargetDecima
730736
731737 constexpr auto min_fractional_value = TargetDecimalType{1 , -4 };
732738
733- if (fmt == chars_format::hex)
734- {
735- return to_chars_hex_impl (first, last, value, precision);
736- }
737-
738739 // Unspecified precision so we always go with the shortest representation
739740 if (precision == -1 )
740741 {
741- if (fmt == chars_format::general || fmt == chars_format::fixed )
742+ switch (fmt)
742743 {
743- if (abs_value >= 1 && abs_value < max_fractional_value)
744- {
744+ case chars_format::general:
745+ if (abs_value >= 1 && abs_value < max_fractional_value)
746+ {
747+ return to_chars_fixed_impl (first, last, value, fmt, precision);
748+ }
749+ else
750+ {
751+ return to_chars_scientific_impl (first, last, value, fmt, precision);
752+ }
753+ case chars_format::fixed:
745754 return to_chars_fixed_impl (first, last, value, fmt, precision);
746- }
747- else
748- {
755+ case chars_format::scientific:
749756 return to_chars_scientific_impl (first, last, value, fmt, precision);
750- }
751- }
752- else
753- {
754- return to_chars_scientific_impl (first, last, value, fmt, precision);
757+ case chars_format::hex:
758+ return to_chars_hex_impl (first, last, value, precision); // LCOV_EXCL_LINE unreachable
755759 }
756760 }
757761 else
@@ -766,13 +770,25 @@ BOOST_DECIMAL_CONSTEXPR auto to_chars_impl(char* first, char* last, TargetDecima
766770 {
767771 return to_chars_fixed_impl (first, last, value, fmt, precision);
768772 }
773+ else if (fmt == chars_format::hex)
774+ {
775+ return to_chars_hex_impl (first, last, value, precision);
776+ }
769777 else
770778 {
771779 return to_chars_scientific_impl (first, last, value, fmt, precision);
772780 }
773781 }
782+
783+ // LCOV_EXCL_START
784+ return to_chars_scientific_impl (first, last, value, fmt, precision);
785+ // LCOV_EXCL_STOP
774786}
775787
788+ #ifdef _MSC_VER
789+ # pragma warning(pop)
790+ #endif
791+
776792} // namespace detail
777793
778794BOOST_DECIMAL_EXPORT BOOST_DECIMAL_CONSTEXPR auto to_chars (char * first, char * last, decimal32 value) noexcept -> to_chars_result
0 commit comments