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
566061d1
Commit
566061d1
authored
Aug 06, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting of signed ints in test.
parent
6cd1563e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
test/printf-test.cc
test/printf-test.cc
+16
-1
No files found.
test/printf-test.cc
View file @
566061d1
...
...
@@ -282,12 +282,27 @@ bool IsSupported(const std::string &format) {
#endif
}
template
<
typename
T
>
struct
MakeSigned
{
typedef
T
Type
;
};
#define SPECIALIZE_MAKE_SIGNED(T, S) \
template <> \
struct MakeSigned<T> { typedef S Type; }
SPECIALIZE_MAKE_SIGNED
(
char
,
signed
char
);
SPECIALIZE_MAKE_SIGNED
(
unsigned
char
,
signed
char
);
SPECIALIZE_MAKE_SIGNED
(
unsigned
short
,
short
);
SPECIALIZE_MAKE_SIGNED
(
unsigned
,
int
);
SPECIALIZE_MAKE_SIGNED
(
unsigned
long
,
long
);
SPECIALIZE_MAKE_SIGNED
(
fmt
::
ULongLong
,
fmt
::
LongLong
);
template
<
typename
T
,
typename
U
>
std
::
string
sprintf_int
(
std
::
string
format
,
U
value
)
{
char
buffer
[
BUFFER_SIZE
];
char
type
=
format
[
format
.
size
()
-
1
];
if
(
type
==
'd'
||
type
==
'i'
)
{
safe_sprintf
(
buffer
,
format
.
c_str
(),
static_cast
<
T
>
(
value
));
typedef
typename
MakeSigned
<
T
>::
Type
Signed
;
safe_sprintf
(
buffer
,
format
.
c_str
(),
static_cast
<
Signed
>
(
value
));
}
else
{
typedef
typename
fmt
::
internal
::
MakeUnsigned
<
T
>::
Type
Unsigned
;
safe_sprintf
(
buffer
,
format
.
c_str
(),
static_cast
<
Unsigned
>
(
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