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
bfedba5a
Commit
bfedba5a
authored
Jan 30, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for int64_t in FormatInt.
parent
c3f5dce8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
format-test.cc
format-test.cc
+3
-0
format.h
format.h
+7
-4
No files found.
format-test.cc
View file @
bfedba5a
...
@@ -1411,6 +1411,9 @@ TEST(FormatterTest, Examples) {
...
@@ -1411,6 +1411,9 @@ TEST(FormatterTest, Examples) {
TEST
(
FormatIntTest
,
FormatInt
)
{
TEST
(
FormatIntTest
,
FormatInt
)
{
EXPECT_EQ
(
"42"
,
fmt
::
FormatInt
(
42
).
str
());
EXPECT_EQ
(
"42"
,
fmt
::
FormatInt
(
42
).
str
());
EXPECT_EQ
(
"-42"
,
fmt
::
FormatInt
(
-
42
).
str
());
EXPECT_EQ
(
"-42"
,
fmt
::
FormatInt
(
-
42
).
str
());
std
::
ostringstream
os
;
os
<<
std
::
numeric_limits
<
int64_t
>::
max
();
EXPECT_EQ
(
os
.
str
(),
fmt
::
FormatInt
(
std
::
numeric_limits
<
int64_t
>::
max
()).
str
());
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
format.h
View file @
bfedba5a
...
@@ -1293,9 +1293,8 @@ class FormatInt {
...
@@ -1293,9 +1293,8 @@ class FormatInt {
return
buffer_end
;
return
buffer_end
;
}
}
public:
void
FormatSigned
(
int64_t
value
)
{
explicit
FormatInt
(
int
value
)
{
uint64_t
abs_value
=
value
;
unsigned
abs_value
=
value
;
bool
negative
=
value
<
0
;
bool
negative
=
value
<
0
;
if
(
negative
)
if
(
negative
)
abs_value
=
0
-
value
;
abs_value
=
0
-
value
;
...
@@ -1303,6 +1302,10 @@ class FormatInt {
...
@@ -1303,6 +1302,10 @@ class FormatInt {
if
(
negative
)
if
(
negative
)
*--
str_
=
'-'
;
*--
str_
=
'-'
;
}
}
public:
explicit
FormatInt
(
int
value
)
{
FormatSigned
(
value
);
}
explicit
FormatInt
(
int64_t
value
)
{
FormatSigned
(
value
);
}
explicit
FormatInt
(
unsigned
value
)
:
str_
(
FormatDecimal
(
value
))
{}
explicit
FormatInt
(
unsigned
value
)
:
str_
(
FormatDecimal
(
value
))
{}
explicit
FormatInt
(
uint64_t
value
)
:
str_
(
FormatDecimal
(
value
))
{}
explicit
FormatInt
(
uint64_t
value
)
:
str_
(
FormatDecimal
(
value
))
{}
...
...
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