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
5079f924
Commit
5079f924
authored
Apr 07, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a narrowing warning
parent
5859e58b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
include/fmt/format.h
include/fmt/format.h
+7
-3
No files found.
include/fmt/format.h
View file @
5079f924
...
...
@@ -930,6 +930,8 @@ inline unsigned count_digits(uint32_t n) {
// A functor that doesn't add a thousands separator.
struct
no_thousands_sep
{
typedef
char
char_type
;
template
<
typename
Char
>
void
operator
()(
Char
*
)
{}
};
...
...
@@ -944,11 +946,12 @@ class add_thousands_sep {
unsigned
digit_index_
;
public:
typedef
Char
char_type
;
explicit
add_thousands_sep
(
basic_string_view
<
Char
>
sep
)
:
sep_
(
sep
),
digit_index_
(
0
)
{}
template
<
typename
BufChar
>
void
operator
()(
BufChar
*&
buffer
)
{
void
operator
()(
Char
*&
buffer
)
{
if
(
++
digit_index_
%
3
!=
0
)
return
;
buffer
-=
sep_
.
size
();
...
...
@@ -993,8 +996,9 @@ inline Char *format_decimal(Char *buffer, UInt value, unsigned num_digits,
template
<
typename
UInt
,
typename
Iterator
,
typename
ThousandsSep
>
inline
Iterator
format_decimal
(
Iterator
out
,
UInt
value
,
unsigned
num_digits
,
ThousandsSep
sep
)
{
typedef
typename
ThousandsSep
::
char_type
char_type
;
// Buffer should be large enough to hold all digits (digits10 + 1) and null.
char
buffer
[
std
::
numeric_limits
<
UInt
>::
digits10
+
2
];
char
_type
buffer
[
std
::
numeric_limits
<
UInt
>::
digits10
+
2
];
format_decimal
(
buffer
,
value
,
num_digits
,
sep
);
return
std
::
copy_n
(
buffer
,
num_digits
,
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