Skip to content

Commit 33b2107

Browse files
committed
Handle path with specified precision on cohort argument
1 parent e4b010b commit 33b2107

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

include/boost/decimal/charconv.hpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,11 +1245,6 @@ constexpr auto to_chars_impl(char* first, char* last, const TargetDecimalType& v
12451245
case chars_format::hex:
12461246
return to_chars_hex_impl(first, last, value);
12471247
case chars_format::cohort_preserving_scientific:
1248-
BOOST_DECIMAL_IF_CONSTEXPR (detail::is_fast_type_v<TargetDecimalType>)
1249-
{
1250-
// Fast types have no concept of cohorts
1251-
return {last, std::errc::invalid_argument};
1252-
}
12531248

12541249
if (local_precision != -1)
12551250
{
@@ -1272,17 +1267,16 @@ constexpr auto to_chars_impl(char* first, char* last, const TargetDecimalType& v
12721267
return to_chars_fixed_impl(first, last, value, fmt, local_precision);
12731268
}
12741269

1275-
if (fmt == chars_format::fixed)
1276-
{
1277-
return to_chars_fixed_impl(first, last, value, fmt, local_precision);
1278-
}
1279-
else if (fmt == chars_format::hex)
1280-
{
1281-
return to_chars_hex_impl(first, last, value, local_precision);
1282-
}
1283-
else
1270+
switch (fmt)
12841271
{
1285-
return to_chars_scientific_impl(first, last, value, fmt, local_precision);
1272+
case chars_format::fixed:
1273+
return to_chars_fixed_impl(first, last, value, fmt, local_precision);
1274+
case chars_format::hex:
1275+
return to_chars_hex_impl(first, last, value, local_precision);
1276+
case chars_format::cohort_preserving_scientific:
1277+
return {last, std::errc::invalid_argument};
1278+
default:
1279+
return to_chars_scientific_impl(first, last, value, fmt, local_precision);
12861280
}
12871281
}
12881282

0 commit comments

Comments
 (0)