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
1289782f
Commit
1289782f
authored
Jul 03, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of add_thousands_sep
parent
2249f557
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
21 deletions
+9
-21
include/fmt/format.h
include/fmt/format.h
+9
-21
No files found.
include/fmt/format.h
View file @
1289782f
...
...
@@ -742,26 +742,6 @@ inline int count_digits(uint32_t n) {
}
#endif
// A callable that adds a thousands separator.
template
<
typename
Char
>
class
add_thousands_sep
{
private:
basic_string_view
<
Char
>
sep_
;
// Index of a decimal digit with the least significant digit having index 0.
unsigned
digit_index_
;
public:
explicit
add_thousands_sep
(
basic_string_view
<
Char
>
sep
)
:
sep_
(
sep
),
digit_index_
(
0
)
{}
void
operator
()(
Char
*&
buffer
)
{
if
(
++
digit_index_
%
3
!=
0
)
return
;
buffer
-=
sep_
.
size
();
std
::
uninitialized_copy
(
sep_
.
data
(),
sep_
.
data
()
+
sep_
.
size
(),
internal
::
make_checked
(
buffer
,
sep_
.
size
()));
}
};
template
<
typename
Char
>
FMT_API
Char
thousands_sep_impl
(
locale_ref
loc
);
template
<
typename
Char
>
inline
Char
thousands_sep
(
locale_ref
loc
)
{
...
...
@@ -1405,8 +1385,16 @@ template <typename Range> class basic_writer {
template
<
typename
It
>
void
operator
()(
It
&&
it
)
const
{
basic_string_view
<
char_type
>
s
(
&
sep
,
SEP_SIZE
);
// Index of a decimal digit with the least significant digit having
// index 0.
unsigned
digit_index
=
0
;
it
=
internal
::
format_decimal
<
char_type
>
(
it
,
abs_value
,
size
,
internal
::
add_thousands_sep
<
char_type
>
(
s
));
it
,
abs_value
,
size
,
[
s
,
&
digit_index
](
char_type
*&
buffer
)
{
if
(
++
digit_index
%
3
!=
0
)
return
;
buffer
-=
s
.
size
();
std
::
uninitialized_copy
(
s
.
data
(),
s
.
data
()
+
s
.
size
(),
internal
::
make_checked
(
buffer
,
s
.
size
()));
});
}
};
...
...
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