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
e900d735
Commit
e900d735
authored
Jun 14, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-enable assert in format_decimal
parent
f4de7b68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
17 deletions
+22
-17
include/fmt/format.h
include/fmt/format.h
+22
-17
No files found.
include/fmt/format.h
View file @
e900d735
...
@@ -895,7 +895,7 @@ template <typename Iterator> struct format_decimal_result {
...
@@ -895,7 +895,7 @@ template <typename Iterator> struct format_decimal_result {
template
<
typename
Char
,
typename
UInt
>
template
<
typename
Char
,
typename
UInt
>
inline
format_decimal_result
<
Char
*>
format_decimal
(
Char
*
out
,
UInt
value
,
inline
format_decimal_result
<
Char
*>
format_decimal
(
Char
*
out
,
UInt
value
,
int
size
)
{
int
size
)
{
//
FMT_ASSERT(size >= count_digits(value), "invalid digit count");
FMT_ASSERT
(
size
>=
count_digits
(
value
),
"invalid digit count"
);
out
+=
size
;
out
+=
size
;
Char
*
end
=
out
;
Char
*
end
=
out
;
while
(
value
>=
100
)
{
while
(
value
>=
100
)
{
...
@@ -2971,25 +2971,28 @@ class format_int {
...
@@ -2971,25 +2971,28 @@ class format_int {
mutable
char
buffer_
[
buffer_size
];
mutable
char
buffer_
[
buffer_size
];
char
*
str_
;
char
*
str_
;
char
*
format_decimal
(
unsigned
long
long
value
)
{
template
<
typename
UInt
>
char
*
format_unsigned
(
UInt
value
)
{
return
detail
::
format_decimal
(
buffer_
,
value
,
buffer_size
-
1
).
begin
;
auto
n
=
static_cast
<
detail
::
uint32_or_64_or_128_t
<
UInt
>>
(
value
);
return
detail
::
format_decimal
(
buffer_
,
n
,
buffer_size
-
1
).
begin
;
}
}
void
format_signed
(
long
long
value
)
{
template
<
typename
Int
>
char
*
format_signed
(
Int
value
)
{
auto
abs_value
=
static_cast
<
unsigned
long
long
>
(
value
);
auto
abs_value
=
static_cast
<
detail
::
uint32_or_64_or_128_t
<
Int
>
>
(
value
);
bool
negative
=
value
<
0
;
bool
negative
=
value
<
0
;
if
(
negative
)
abs_value
=
0
-
abs_value
;
if
(
negative
)
abs_value
=
0
-
abs_value
;
str_
=
format_decimal
(
abs_value
);
auto
begin
=
format_unsigned
(
abs_value
);
if
(
negative
)
*--
str_
=
'-'
;
if
(
negative
)
*--
begin
=
'-'
;
return
begin
;
}
}
public:
public:
explicit
format_int
(
int
value
)
{
format_signed
(
value
);
}
explicit
format_int
(
int
value
)
:
str_
(
format_signed
(
value
))
{}
explicit
format_int
(
long
value
)
{
format_signed
(
value
);
}
explicit
format_int
(
long
value
)
:
str_
(
format_signed
(
value
))
{}
explicit
format_int
(
long
long
value
)
{
format_signed
(
value
);
}
explicit
format_int
(
long
long
value
)
:
str_
(
format_signed
(
value
))
{}
explicit
format_int
(
unsigned
value
)
:
str_
(
format_decimal
(
value
))
{}
explicit
format_int
(
unsigned
value
)
:
str_
(
format_unsigned
(
value
))
{}
explicit
format_int
(
unsigned
long
value
)
:
str_
(
format_decimal
(
value
))
{}
explicit
format_int
(
unsigned
long
value
)
:
str_
(
format_unsigned
(
value
))
{}
explicit
format_int
(
unsigned
long
long
value
)
:
str_
(
format_decimal
(
value
))
{}
explicit
format_int
(
unsigned
long
long
value
)
:
str_
(
format_unsigned
(
value
))
{}
/** Returns the number of characters written to the output buffer. */
/** Returns the number of characters written to the output buffer. */
size_t
size
()
const
{
size_t
size
()
const
{
...
@@ -3370,13 +3373,15 @@ template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
...
@@ -3370,13 +3373,15 @@ template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
inline
std
::
string
to_string
(
const
T
&
value
)
{
inline
std
::
string
to_string
(
const
T
&
value
)
{
return
format
(
"{}"
,
value
);
return
format
(
"{}"
,
value
);
}
}
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_integral
<
T
>
::
value
)
>
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_integral
<
T
>
::
value
)
>
inline
std
::
string
to_string
(
T
value
)
{
inline
std
::
string
to_string
(
T
value
)
{
// Buffer should be large enough to store the number or "false" (for bool).
// The buffer should be large enough to store the number including the sign or
char
buffer
[(
std
::
max
)(
detail
::
digits10
<
T
>
()
+
2
,
5
)];
// "false" for bool.
constexpr
int
max_size
=
detail
::
digits10
<
T
>
()
+
2
;
char
buffer
[
max_size
>
5
?
max_size
:
5
];
char
*
begin
=
buffer
;
char
*
begin
=
buffer
;
char
*
end
=
detail
::
write
<
char
>
(
begin
,
value
);
return
std
::
string
(
begin
,
detail
::
write
<
char
>
(
begin
,
value
));
return
std
::
string
(
begin
,
end
);
}
}
/**
/**
...
...
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