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
f487ddbd
Commit
f487ddbd
authored
Jul 03, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thousands_sep -> add_thousands_sep
parent
d8fd1699
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
include/fmt/format.h
include/fmt/format.h
+10
-11
No files found.
include/fmt/format.h
View file @
f487ddbd
...
...
@@ -752,11 +752,11 @@ template <> inline wchar_t thousands_sep(locale_ref loc) {
}
// Formats a decimal unsigned integer value writing into buffer.
//
thousands_sep is a functor that is called after writing each char to
//
add a thousands
separator if necessary.
template
<
typename
UInt
,
typename
Char
,
typename
ThousandsSep
>
//
add_thousands_sep is called after writing each char to add a thousands
// separator if necessary.
template
<
typename
UInt
,
typename
Char
,
typename
F
>
inline
Char
*
format_decimal
(
Char
*
buffer
,
UInt
value
,
int
num_digits
,
ThousandsSep
thousands_sep
)
{
F
add_
thousands_sep
)
{
FMT_ASSERT
(
num_digits
>=
0
,
"invalid digit count"
);
buffer
+=
num_digits
;
Char
*
end
=
buffer
;
...
...
@@ -767,9 +767,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
unsigned
index
=
static_cast
<
unsigned
>
((
value
%
100
)
*
2
);
value
/=
100
;
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
+
1
]);
thousands_sep
(
buffer
);
add_
thousands_sep
(
buffer
);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
]);
thousands_sep
(
buffer
);
add_
thousands_sep
(
buffer
);
}
if
(
value
<
10
)
{
*--
buffer
=
static_cast
<
Char
>
(
'0'
+
value
);
...
...
@@ -777,20 +777,19 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
}
unsigned
index
=
static_cast
<
unsigned
>
(
value
*
2
);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
+
1
]);
thousands_sep
(
buffer
);
add_
thousands_sep
(
buffer
);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
]);
return
end
;
}
template
<
typename
Char
,
typename
UInt
,
typename
Iterator
,
typename
ThousandsSep
>
template
<
typename
Char
,
typename
UInt
,
typename
Iterator
,
typename
F
>
inline
Iterator
format_decimal
(
Iterator
out
,
UInt
value
,
int
num_digits
,
ThousandsSep
sep
)
{
F
add_thousands_
sep
)
{
FMT_ASSERT
(
num_digits
>=
0
,
"invalid digit count"
);
// Buffer should be large enough to hold all digits (<= digits10 + 1).
enum
{
max_size
=
std
::
numeric_limits
<
UInt
>::
digits10
+
1
};
Char
buffer
[
max_size
+
max_size
/
3
];
auto
end
=
format_decimal
(
buffer
,
value
,
num_digits
,
sep
);
auto
end
=
format_decimal
(
buffer
,
value
,
num_digits
,
add_thousands_
sep
);
return
internal
::
copy_str
<
Char
>
(
buffer
,
end
,
out
);
}
...
...
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