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
d5c46259
Commit
d5c46259
authored
Jun 05, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix formatting of more than 15 named arguments (#754)
parent
47d147b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
14 deletions
+15
-14
include/fmt/core.h
include/fmt/core.h
+5
-5
include/fmt/format.h
include/fmt/format.h
+5
-9
test/format-test.cc
test/format-test.cc
+5
-0
No files found.
include/fmt/core.h
View file @
d5c46259
...
...
@@ -428,7 +428,7 @@ template <typename T, typename Char>
struct
is_named_arg
<
named_arg
<
T
,
Char
>>
:
std
::
true_type
{};
enum
type
{
none_type
,
name_arg_type
,
none_type
,
name
d
_arg_type
,
// Integer types should go first,
int_type
,
uint_type
,
long_long_type
,
ulong_long_type
,
bool_type
,
char_type
,
last_integer_type
=
char_type
,
...
...
@@ -438,12 +438,12 @@ enum type {
};
FMT_CONSTEXPR
bool
is_integral
(
type
t
)
{
FMT_ASSERT
(
t
!=
internal
::
name_arg_type
,
"invalid argument type"
);
FMT_ASSERT
(
t
!=
internal
::
name
d
_arg_type
,
"invalid argument type"
);
return
t
>
internal
::
none_type
&&
t
<=
internal
::
last_integer_type
;
}
FMT_CONSTEXPR
bool
is_arithmetic
(
type
t
)
{
FMT_ASSERT
(
t
!=
internal
::
name_arg_type
,
"invalid argument type"
);
FMT_ASSERT
(
t
!=
internal
::
name
d
_arg_type
,
"invalid argument type"
);
return
t
>
internal
::
none_type
&&
t
<=
internal
::
last_numeric_type
;
}
...
...
@@ -637,7 +637,7 @@ inline typename std::enable_if<
make_value
(
const
T
&
val
)
{
return
val
;
}
template
<
typename
C
,
typename
T
>
typed_value
<
C
,
name_arg_type
>
typed_value
<
C
,
name
d
_arg_type
>
make_value
(
const
named_arg
<
T
,
typename
C
::
char_type
>
&
val
)
{
basic_format_arg
<
C
>
arg
=
make_arg
<
C
>
(
val
.
value
);
std
::
memcpy
(
val
.
data
,
&
arg
,
sizeof
(
arg
));
...
...
@@ -1088,7 +1088,7 @@ class basic_format_args {
/** Returns the argument at specified index. */
format_arg
get
(
size_type
index
)
const
{
format_arg
arg
=
do_get
(
index
);
return
arg
.
type_
==
internal
::
name_arg_type
?
return
arg
.
type_
==
internal
::
name
d
_arg_type
?
arg
.
value_
.
as_named_arg
().
template
deserialize
<
Context
>()
:
arg
;
}
...
...
include/fmt/format.h
View file @
d5c46259
...
...
@@ -1199,7 +1199,7 @@ FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
switch
(
arg
.
type_
)
{
case
internal
:
:
none_type
:
break
;
case
internal
:
:
name_arg_type
:
case
internal
:
:
name
d
_arg_type
:
FMT_ASSERT
(
false
,
"invalid argument type"
);
break
;
case
internal
:
:
int_type
:
...
...
@@ -1493,7 +1493,7 @@ void arg_map<Context>::init(const basic_format_args<Context> &args) {
switch
(
arg_type
)
{
case
internal
:
:
none_type
:
return
;
case
internal
:
:
name_arg_type
:
case
internal
:
:
name
d
_arg_type
:
push_back
(
args
.
values_
[
i
]);
break
;
default:
...
...
@@ -1502,15 +1502,11 @@ void arg_map<Context>::init(const basic_format_args<Context> &args) {
}
return
;
}
for
(
unsigned
i
=
0
;
i
!=
max_packed_args
;
++
i
)
{
if
(
args
.
type
(
i
)
==
internal
::
name_arg_type
)
push_back
(
args
.
args_
[
i
].
value_
);
}
for
(
unsigned
i
=
max_packed_args
;
;
++
i
)
{
for
(
unsigned
i
=
0
;
;
++
i
)
{
switch
(
args
.
args_
[
i
].
type_
)
{
case
internal
:
:
none_type
:
return
;
case
internal
:
:
name_arg_type
:
case
internal
:
:
name
d
_arg_type
:
push_back
(
args
.
args_
[
i
].
value_
);
break
;
default:
...
...
@@ -3172,7 +3168,7 @@ struct formatter<
auto
eh
=
ctx
.
error_handler
();
switch
(
type
)
{
case
internal
:
:
none_type
:
case
internal
:
:
name_arg_type
:
case
internal
:
:
name
d
_arg_type
:
FMT_ASSERT
(
false
,
"invalid argument type"
);
break
;
case
internal
:
:
int_type
:
...
...
test/format-test.cc
View file @
d5c46259
...
...
@@ -321,6 +321,11 @@ TEST(FormatterTest, NamedArg) {
EXPECT_EQ
(
" -42"
,
format
(
"{0:{width}}"
,
-
42
,
fmt
::
arg
(
"width"
,
4
)));
EXPECT_EQ
(
"st"
,
format
(
"{0:.{precision}}"
,
"str"
,
fmt
::
arg
(
"precision"
,
2
)));
EXPECT_EQ
(
"1 2"
,
format
(
"{} {two}"
,
1
,
fmt
::
arg
(
"two"
,
2
)));
EXPECT_EQ
(
"42"
,
format
(
"{c}"
,
fmt
::
arg
(
"a"
,
0
),
fmt
::
arg
(
"b"
,
0
),
fmt
::
arg
(
"c"
,
42
),
fmt
::
arg
(
"d"
,
0
),
fmt
::
arg
(
"e"
,
0
),
fmt
::
arg
(
"f"
,
0
),
fmt
::
arg
(
"g"
,
0
),
fmt
::
arg
(
"h"
,
0
),
fmt
::
arg
(
"i"
,
0
),
fmt
::
arg
(
"j"
,
0
),
fmt
::
arg
(
"k"
,
0
),
fmt
::
arg
(
"l"
,
0
),
fmt
::
arg
(
"m"
,
0
),
fmt
::
arg
(
"n"
,
0
),
fmt
::
arg
(
"o"
,
0
),
fmt
::
arg
(
"p"
,
0
)));
}
TEST
(
FormatterTest
,
AutoArgIndex
)
{
...
...
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