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
c286ffc8
Commit
c286ffc8
authored
Jul 03, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
int_traits -> uint32_or_64_t
parent
1289782f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
15 deletions
+10
-15
include/fmt/chrono.h
include/fmt/chrono.h
+1
-2
include/fmt/format-inl.h
include/fmt/format-inl.h
+1
-2
include/fmt/format.h
include/fmt/format.h
+7
-9
include/fmt/printf.h
include/fmt/printf.h
+1
-2
No files found.
include/fmt/chrono.h
View file @
c286ffc8
...
...
@@ -579,8 +579,7 @@ struct chrono_formatter {
void
write
(
Rep
value
,
int
width
)
{
write_sign
();
if
(
isnan
(
value
))
return
write_nan
();
typedef
typename
int_traits
<
int
>::
main_type
main_type
;
main_type
n
=
to_unsigned
(
uint32_or_64_t
<
int
>
n
=
to_unsigned
(
to_nonnegative_int
(
value
,
(
std
::
numeric_limits
<
int
>::
max
)()));
int
num_digits
=
internal
::
count_digits
(
n
);
if
(
width
>
num_digits
)
out
=
std
::
fill_n
(
out
,
width
-
num_digits
,
'0'
);
...
...
include/fmt/format-inl.h
View file @
c286ffc8
...
...
@@ -157,8 +157,7 @@ FMT_FUNC void format_error_code(internal::buffer<char>& out, int error_code,
static
const
char
ERROR_STR
[]
=
"error "
;
// Subtract 2 to account for terminating null characters in SEP and ERROR_STR.
std
::
size_t
error_code_size
=
sizeof
(
SEP
)
+
sizeof
(
ERROR_STR
)
-
2
;
typedef
internal
::
int_traits
<
int
>::
main_type
main_type
;
main_type
abs_value
=
static_cast
<
main_type
>
(
error_code
);
auto
abs_value
=
static_cast
<
uint32_or_64_t
<
int
>>
(
error_code
);
if
(
internal
::
is_negative
(
error_code
))
{
abs_value
=
0
-
abs_value
;
++
error_code_size
;
...
...
include/fmt/format.h
View file @
c286ffc8
...
...
@@ -606,12 +606,11 @@ FMT_CONSTEXPR bool is_negative(T) {
return
false
;
}
template
<
typename
T
>
struct
int_traits
{
// Smallest of uint32_t and uint64_t that is large enough to represent
// all values of T.
using
main_type
=
conditional_t
<
std
::
numeric_limits
<
T
>::
digits
<=
32
,
uint32_t
,
uint64_t
>
;
};
// Smallest of uint32_t and uint64_t that is large enough to represent all
// values of T.
template
<
typename
T
>
using
uint32_or_64_t
=
conditional_t
<
std
::
numeric_limits
<
T
>::
digits
<=
32
,
uint32_t
,
uint64_t
>
;
// Static data is placed in this class template for the header-only config.
template
<
typename
T
=
void
>
struct
FMT_EXTERN_TEMPLATE_API
basic_data
{
...
...
@@ -1273,8 +1272,7 @@ template <typename Range> class basic_writer {
// Writes a decimal integer.
template
<
typename
Int
>
void
write_decimal
(
Int
value
)
{
typedef
typename
internal
::
int_traits
<
Int
>::
main_type
main_type
;
main_type
abs_value
=
static_cast
<
main_type
>
(
value
);
auto
abs_value
=
static_cast
<
uint32_or_64_t
<
Int
>>
(
value
);
bool
is_negative
=
internal
::
is_negative
(
value
);
if
(
is_negative
)
abs_value
=
0
-
abs_value
;
int
num_digits
=
internal
::
count_digits
(
abs_value
);
...
...
@@ -1286,7 +1284,7 @@ template <typename Range> class basic_writer {
// The handle_int_type_spec handler that writes an integer.
template
<
typename
Int
,
typename
Spec
>
struct
int_writer
{
typedef
typename
internal
::
int_traits
<
Int
>::
main_type
unsigned_type
;
using
unsigned_type
=
uint32_or_64_t
<
Int
>
;
basic_writer
<
Range
>&
writer
;
const
Spec
&
spec
;
...
...
include/fmt/printf.h
View file @
c286ffc8
...
...
@@ -158,8 +158,7 @@ template <typename Char> class printf_width_handler {
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_integral
<
T
>
::
value
)
>
unsigned
operator
()(
T
value
)
{
typedef
typename
internal
::
int_traits
<
T
>::
main_type
UnsignedType
;
UnsignedType
width
=
static_cast
<
UnsignedType
>
(
value
);
auto
width
=
static_cast
<
uint32_or_64_t
<
T
>>
(
value
);
if
(
internal
::
is_negative
(
value
))
{
spec_
.
align_
=
ALIGN_LEFT
;
width
=
0
-
width
;
...
...
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