Skip to content

Commit a4f0501

Browse files
authored
Merge pull request #1172 from cppalliance/fix_locale
2 parents 5ed4129 + 1205f95 commit a4f0501

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

doc/modules/ROOT/pages/format.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ IMPORTANT: `std::format` only supports `char` and `wchar_t` types per the pass:[
8383

8484
The appropriate order for the full format specifier is:
8585

86-
String literal pass:["{Locale, Sign, Padding, Precision, Type}"]
86+
String literal pass:["{Sign, Padding, Precision, Type, Locale}"]
8787

8888
=== Examples
8989

include/boost/decimal/fmt_format.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,6 @@ constexpr auto parse_impl(ParseContext &ctx)
6767
return std::make_tuple(ctx_precision, fmt, is_upper, padding_digits, sign_character, use_locale, it);
6868
}
6969

70-
// Check for the locale character
71-
if (*it == static_cast<CharType>('L'))
72-
{
73-
use_locale = true;
74-
++it;
75-
}
76-
7770
// Check for a sign character
7871
if (it != ctx.end())
7972
{
@@ -177,6 +170,13 @@ constexpr auto parse_impl(ParseContext &ctx)
177170
++it;
178171
}
179172

173+
// Check for the locale character
174+
if (it != ctx.end() && *it == static_cast<CharType>('L'))
175+
{
176+
use_locale = true;
177+
++it;
178+
}
179+
180180
// Verify we're at the closing brace
181181
if (it != ctx.end() && *it != static_cast<CharType>('}'))
182182
{

include/boost/decimal/format.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ constexpr auto parse_impl(ParseContext &ctx)
5252
int padding_digits = 0;
5353
bool use_locale = false;
5454

55-
// Check for the locale character
56-
if (*it == static_cast<CharType>('L'))
57-
{
58-
use_locale = true;
59-
++it;
60-
}
61-
6255
// Check for a sign character
6356
if (it != ctx.end())
6457
{
@@ -153,6 +146,13 @@ constexpr auto parse_impl(ParseContext &ctx)
153146
++it;
154147
}
155148

149+
// Check for the locale character
150+
if (it != ctx.end() && *it == static_cast<CharType>('L'))
151+
{
152+
use_locale = true;
153+
++it;
154+
}
155+
156156
// Verify we're at the closing brace
157157
if (it != ctx.end() && *it != static_cast<CharType>('}'))
158158
{

test/test_format.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void test_locale_conversion(const char* locale, const std::string& result)
255255
std::locale::global(a);
256256

257257
const T value {112289, -2};
258-
BOOST_TEST_EQ(std::format("{:L.2f}", value), result);
258+
BOOST_TEST_EQ(std::format("{:.2fL}", value), result);
259259
}
260260
// LCOV_EXCL_START
261261
catch (...)

test/test_format_fmtlib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void test_locale_conversion(const char* locale, const std::string& result)
279279
std::locale::global(a);
280280

281281
const T value {112289, -2};
282-
BOOST_TEST_EQ(fmt::format("{:L.2f}", value), result);
282+
BOOST_TEST_EQ(fmt::format("{:.2fL}", value), result);
283283
}
284284
// LCOV_EXCL_START
285285
catch (...)

0 commit comments

Comments
 (0)