Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
33efc3c9
Commit
33efc3c9
authored
Jul 30, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of iterators in locale-specific formatting (#1782)
parent
b9d74909
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
include/fmt/format.h
include/fmt/format.h
+5
-4
test/locale-test.cc
test/locale-test.cc
+12
-0
No files found.
include/fmt/format.h
View file @
33efc3c9
...
@@ -745,9 +745,9 @@ FMT_CONSTEXPR bool is_supported_floating_point(T) {
...
@@ -745,9 +745,9 @@ FMT_CONSTEXPR bool is_supported_floating_point(T) {
// Smallest of uint32_t, uint64_t, uint128_t that is large enough to
// Smallest of uint32_t, uint64_t, uint128_t that is large enough to
// represent all values of T.
// represent all values of T.
template
<
typename
T
>
template
<
typename
T
>
using
uint32_or_64_or_128_t
=
conditional_t
<
using
uint32_or_64_or_128_t
=
num_bits
<
T
>
()
<=
32
,
uint32_t
,
conditional_t
<
num_bits
<
T
>
()
<=
32
,
uint32_t
,
conditional_t
<
num_bits
<
T
>
()
<=
64
,
uint64_t
,
uint128_t
>>
;
conditional_t
<
num_bits
<
T
>
()
<=
64
,
uint64_t
,
uint128_t
>>
;
// Static data is placed in this class template for the header-only config.
// Static data is placed in this class template for the header-only config.
template
<
typename
T
=
void
>
struct
FMT_EXTERN_TEMPLATE_API
basic_data
{
template
<
typename
T
=
void
>
struct
FMT_EXTERN_TEMPLATE_API
basic_data
{
...
@@ -1593,7 +1593,8 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
...
@@ -1593,7 +1593,8 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
make_checked
(
p
,
s
.
size
()));
make_checked
(
p
,
s
.
size
()));
}
}
if
(
prefix_size
!=
0
)
p
[
-
1
]
=
static_cast
<
Char
>
(
'-'
);
if
(
prefix_size
!=
0
)
p
[
-
1
]
=
static_cast
<
Char
>
(
'-'
);
write
(
out
,
basic_string_view
<
Char
>
(
buffer
.
data
(),
buffer
.
size
()),
specs
);
out
=
write
(
out
,
basic_string_view
<
Char
>
(
buffer
.
data
(),
buffer
.
size
()),
specs
);
}
}
void
on_chr
()
{
*
out
++
=
static_cast
<
Char
>
(
abs_value
);
}
void
on_chr
()
{
*
out
++
=
static_cast
<
Char
>
(
abs_value
);
}
...
...
test/locale-test.cc
View file @
33efc3c9
...
@@ -89,4 +89,16 @@ TEST(LocaleTest, WFormat) {
...
@@ -89,4 +89,16 @@ TEST(LocaleTest, WFormat) {
fmt
::
format
(
small_grouping_loc
,
L"{:L}"
,
max_value
<
uint32_t
>
()));
fmt
::
format
(
small_grouping_loc
,
L"{:L}"
,
max_value
<
uint32_t
>
()));
}
}
TEST
(
LocaleTest
,
DoubleFormatter
)
{
auto
loc
=
std
::
locale
(
std
::
locale
(),
new
special_grouping
<
char
>
());
auto
f
=
fmt
::
formatter
<
int
>
();
auto
parse_ctx
=
fmt
::
format_parse_context
(
"L"
);
f
.
parse
(
parse_ctx
);
char
buf
[
10
]
=
{};
fmt
::
basic_format_context
<
char
*
,
char
>
format_ctx
(
buf
,
{},
fmt
::
detail
::
locale_ref
(
loc
));
*
f
.
format
(
12345
,
format_ctx
)
=
0
;
EXPECT_STREQ
(
"12,345"
,
buf
);
}
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
#endif // FMT_STATIC_THOUSANDS_SEPARATOR
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment