Skip to content

Commit 501f528

Browse files
committed
Add in processing of a new A option
1 parent 1256698 commit 501f528

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

include/boost/decimal/fmt_format.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ constexpr auto parse_impl(ParseContext &ctx)
124124
case 'x':
125125
fmt = chars_format::hex;
126126
break;
127+
128+
case 'A':
129+
if (ctx_precision != -1)
130+
{
131+
BOOST_DECIMAL_THROW_EXCEPTION(std::logic_error("Cohort preservation is mutually exclusive with precision"));
132+
}
133+
134+
is_upper = true;
135+
fmt = chars_format::cohort_preserving_scientific;
136+
break;
137+
case 'a':
138+
if (ctx_precision != -1)
139+
{
140+
BOOST_DECIMAL_THROW_EXCEPTION(std::logic_error("Cohort preservation is mutually exclusive with precision"));
141+
}
142+
143+
fmt = chars_format::cohort_preserving_scientific;
144+
break;
127145
// LCOV_EXCL_START
128146
default:
129147
BOOST_DECIMAL_THROW_EXCEPTION(std::logic_error("Invalid format specifier"));

include/boost/decimal/format.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// Fixed :f
2626
// Scientific :e
2727
// Hex :x
28+
// Cohort Preserving :a
2829
//
2930
// Capital letter for any of the above leads to all characters being uppercase
3031

@@ -120,6 +121,19 @@ constexpr auto parse_impl(ParseContext &ctx)
120121
case 'x':
121122
fmt = chars_format::hex;
122123
break;
124+
125+
case 'A':
126+
is_upper = true;
127+
[[fallthrough]];
128+
case 'a':
129+
if (ctx_precision != -1)
130+
{
131+
BOOST_DECIMAL_THROW_EXCEPTION(std::format_error("Cohort preservation is mutually exclusive with precision"));
132+
}
133+
134+
fmt = chars_format::cohort_preserving_scientific;
135+
break;
136+
123137
// LCOV_EXCL_START
124138
default:
125139
BOOST_DECIMAL_THROW_EXCEPTION(std::format_error("Invalid format specifier"));

0 commit comments

Comments
 (0)