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
2d2326a7
Commit
2d2326a7
authored
Oct 22, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation with older gcc
parent
1ec02723
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
20 deletions
+26
-20
CMakeLists.txt
CMakeLists.txt
+1
-1
include/fmt/format-inl.h
include/fmt/format-inl.h
+9
-8
include/fmt/format.h
include/fmt/format.h
+16
-11
No files found.
CMakeLists.txt
View file @
2d2326a7
...
...
@@ -68,7 +68,7 @@ include(CheckCXXCompilerFlag)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU"
)
set
(
PEDANTIC_COMPILE_FLAGS -pedantic-errors -Wall -Wextra -pedantic
-Wold-style-cast -W
logical-op -W
undef
-Wold-style-cast -Wundef
-Wredundant-decls -Wshadow -Wwrite-strings -Wpointer-arith
-Wcast-qual -Wformat=2 -Wmissing-include-dirs
-Wcast-align -Wnon-virtual-dtor
...
...
include/fmt/format-inl.h
View file @
2d2326a7
...
...
@@ -603,6 +603,15 @@ FMT_FUNC void write_exponent(int exp, Handler &&h) {
}
}
struct
fill
{
size_t
n
;
void
operator
()(
char
*
buffer
)
const
{
buffer
[
0
]
=
'0'
;
buffer
[
1
]
=
'.'
;
std
::
uninitialized_fill_n
(
buffer
+
2
,
n
,
'0'
);
}
};
// The number is given as v = f * pow(10, exp), where f has size digits.
template
<
typename
Handler
>
FMT_FUNC
void
grisu2_prettify
(
const
gen_digits_params
&
params
,
...
...
@@ -642,14 +651,6 @@ FMT_FUNC void grisu2_prettify(const gen_digits_params ¶ms,
}
}
else
{
// 1234e-6 -> 0.001234
struct
fill
{
size_t
n
;
void
operator
()(
char
*
buffer
)
const
{
buffer
[
0
]
=
'0'
;
buffer
[
1
]
=
'.'
;
std
::
uninitialized_fill_n
(
buffer
+
2
,
n
,
'0'
);
}
};
handler
.
insert
(
0
,
2
-
full_exp
,
fill
{
to_unsigned
(
-
full_exp
)});
}
}
...
...
include/fmt/format.h
View file @
2d2326a7
...
...
@@ -1779,8 +1779,9 @@ struct arg_ref {
FMT_CONSTEXPR
arg_ref
()
:
kind
(
NONE
),
index
(
0
)
{}
FMT_CONSTEXPR
explicit
arg_ref
(
unsigned
index
)
:
kind
(
INDEX
),
index
(
index
)
{}
explicit
arg_ref
(
basic_string_view
<
Char
>
name
)
:
kind
(
NAME
),
name
{
name
.
data
(),
name
.
size
()}
{}
explicit
arg_ref
(
basic_string_view
<
Char
>
nm
)
:
kind
(
NAME
)
{
name
=
{
nm
.
data
(),
nm
.
size
()};
}
FMT_CONSTEXPR
arg_ref
&
operator
=
(
unsigned
idx
)
{
kind
=
INDEX
;
...
...
@@ -3401,24 +3402,27 @@ struct format_to_n_result {
};
template
<
typename
OutputIt
,
typename
Char
=
typename
OutputIt
::
value_type
>
using
format_to_n_context
=
typename
fmt
::
format_context_t
<
f
mt
::
internal
::
truncating_iterator
<
OutputIt
>
,
Char
>::
type
;
struct
format_to_n_context
:
f
ormat_context_t
<
fmt
::
internal
::
truncating_iterator
<
OutputIt
>
,
Char
>
{}
;
template
<
typename
OutputIt
,
typename
Char
=
typename
OutputIt
::
value_type
>
using
format_to_n_args
=
fmt
::
basic_format_args
<
format_to_n_context
<
OutputIt
,
Char
>>
;
struct
format_to_n_args
{
typedef
basic_format_args
<
typename
format_to_n_context
<
OutputIt
,
Char
>::
type
>
type
;
};
template
<
typename
OutputIt
,
typename
Char
,
typename
...
Args
>
inline
format_arg_store
<
format_to_n_context
<
OutputIt
,
Char
>
,
Args
...
>
inline
format_arg_store
<
typename
format_to_n_context
<
OutputIt
,
Char
>::
type
,
Args
...
>
make_format_to_n_args
(
const
Args
&
...
args
)
{
return
format_arg_store
<
format_to_n_context
<
OutputIt
,
Char
>
,
Args
...
>
(
args
...);
typename
format_to_n_context
<
OutputIt
,
Char
>::
type
,
Args
...
>
(
args
...);
}
template
<
typename
OutputIt
,
typename
Char
,
typename
...
Args
>
inline
format_to_n_result
<
OutputIt
>
vformat_to_n
(
OutputIt
out
,
std
::
size_t
n
,
basic_string_view
<
Char
>
format_str
,
format_to_n_args
<
OutputIt
,
Char
>
args
)
{
typename
format_to_n_args
<
OutputIt
,
Char
>::
type
args
)
{
typedef
internal
::
truncating_iterator
<
OutputIt
>
It
;
auto
it
=
vformat_to
(
It
(
out
,
n
),
format_str
,
args
);
return
{
it
.
base
(),
it
.
count
()};
...
...
@@ -3437,9 +3441,10 @@ inline FMT_ENABLE_IF_STRING(S, format_to_n_result<OutputIt>)
const
Args
&
...
args
)
{
internal
::
check_format_string
<
Args
...
>
(
format_str
);
typedef
FMT_CHAR
(
S
)
Char
;
format_arg_store
<
format_to_n_context
<
OutputIt
,
Char
>
,
Args
...
>
as
(
args
...);
format_arg_store
<
typename
format_to_n_context
<
OutputIt
,
Char
>::
type
,
Args
...
>
as
(
args
...);
return
vformat_to_n
(
out
,
n
,
to_string_view
(
format_str
),
format_to_n_args
<
OutputIt
,
Char
>
(
as
));
typename
format_to_n_args
<
OutputIt
,
Char
>::
type
(
as
));
}
template
<
typename
Char
>
...
...
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