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
5ddf9ee1
Commit
5ddf9ee1
authored
Jun 20, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Streamline default FP formatting
parent
0b3a83f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
1 deletion
+26
-1
include/fmt/format.h
include/fmt/format.h
+26
-1
No files found.
include/fmt/format.h
View file @
5ddf9ee1
...
@@ -1611,7 +1611,7 @@ OutputIt write_nonfinite(OutputIt out, bool isinf,
...
@@ -1611,7 +1611,7 @@ OutputIt write_nonfinite(OutputIt out, bool isinf,
template
<
typename
Char
,
typename
OutputIt
,
typename
T
,
template
<
typename
Char
,
typename
OutputIt
,
typename
T
,
FMT_ENABLE_IF
(
std
::
is_floating_point
<
T
>
::
value
)
>
FMT_ENABLE_IF
(
std
::
is_floating_point
<
T
>
::
value
)
>
OutputIt
write
(
OutputIt
out
,
T
value
,
basic_format_specs
<
Char
>
specs
=
{}
,
OutputIt
write
(
OutputIt
out
,
T
value
,
basic_format_specs
<
Char
>
specs
,
locale_ref
loc
=
{})
{
locale_ref
loc
=
{})
{
if
(
const_check
(
!
is_supported_floating_point
(
value
)))
return
out
;
if
(
const_check
(
!
is_supported_floating_point
(
value
)))
return
out
;
float_specs
fspecs
=
parse_float_type_spec
(
specs
);
float_specs
fspecs
=
parse_float_type_spec
(
specs
);
...
@@ -1658,6 +1658,31 @@ OutputIt write(OutputIt out, T value, basic_format_specs<Char> specs = {},
...
@@ -1658,6 +1658,31 @@ OutputIt write(OutputIt out, T value, basic_format_specs<Char> specs = {},
return
write_padded
<
align
::
right
>
(
out
,
specs
,
w
.
size
(),
w
);
return
write_padded
<
align
::
right
>
(
out
,
specs
,
w
.
size
(),
w
);
}
}
template
<
typename
Char
,
typename
OutputIt
,
typename
T
,
FMT_ENABLE_IF
(
std
::
is_floating_point
<
T
>
::
value
)
>
OutputIt
write
(
OutputIt
out
,
T
value
)
{
if
(
const_check
(
!
is_supported_floating_point
(
value
)))
return
out
;
auto
fspecs
=
float_specs
();
if
(
std
::
signbit
(
value
))
{
// value < 0 is false for NaN so use signbit.
fspecs
.
sign
=
sign
::
minus
;
value
=
-
value
;
}
auto
specs
=
basic_format_specs
<
Char
>
();
if
(
!
std
::
isfinite
(
value
))
return
write_nonfinite
(
out
,
std
::
isinf
(
value
),
specs
,
fspecs
);
memory_buffer
buffer
;
int
precision
=
-
1
;
if
(
const_check
(
std
::
is_same
<
T
,
float
>
()))
fspecs
.
binary32
=
true
;
fspecs
.
use_grisu
=
use_grisu
<
T
>
();
int
exp
=
format_float
(
promote_float
(
value
),
precision
,
fspecs
,
buffer
);
fspecs
.
precision
=
precision
;
float_writer
<
Char
>
w
(
buffer
.
data
(),
static_cast
<
int
>
(
buffer
.
size
()),
exp
,
fspecs
,
static_cast
<
Char
>
(
'.'
));
return
base_iterator
(
out
,
w
(
reserve
(
out
,
w
.
size
())));
}
template
<
typename
Char
,
typename
OutputIt
>
template
<
typename
Char
,
typename
OutputIt
>
OutputIt
write_char
(
OutputIt
out
,
Char
value
,
OutputIt
write_char
(
OutputIt
out
,
Char
value
,
const
basic_format_specs
<
Char
>&
specs
)
{
const
basic_format_specs
<
Char
>&
specs
)
{
...
...
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