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
16637341
Commit
16637341
authored
Jun 12, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable compilation for all types
parent
2d71d7e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
include/fmt/compile.h
include/fmt/compile.h
+3
-7
test/compile-test.cc
test/compile-test.cc
+7
-0
No files found.
include/fmt/compile.h
View file @
16637341
...
@@ -468,12 +468,8 @@ constexpr auto compile_format_string(S format_str) {
...
@@ -468,12 +468,8 @@ constexpr auto compile_format_string(S format_str) {
return
parse_tail
<
Args
,
POS
+
2
,
ID
>
(
make_text
(
str
,
POS
,
1
),
format_str
);
return
parse_tail
<
Args
,
POS
+
2
,
ID
>
(
make_text
(
str
,
POS
,
1
),
format_str
);
}
else
if
constexpr
(
str
[
POS
+
1
]
==
'}'
)
{
}
else
if
constexpr
(
str
[
POS
+
1
]
==
'}'
)
{
using
type
=
get_type
<
ID
,
Args
>
;
using
type
=
get_type
<
ID
,
Args
>
;
if
constexpr
(
std
::
is_same
<
type
,
int
>::
value
)
{
return
parse_tail
<
Args
,
POS
+
2
,
ID
+
1
>
(
field
<
char_type
,
type
,
ID
>
(),
return
parse_tail
<
Args
,
POS
+
2
,
ID
+
1
>
(
field
<
char_type
,
type
,
ID
>
(),
format_str
);
format_str
);
}
else
{
return
unknown_format
();
}
}
else
{
}
else
{
return
unknown_format
();
return
unknown_format
();
}
}
...
@@ -565,7 +561,7 @@ FMT_INLINE std::basic_string<typename S::char_type> format(S, Args&&... args) {
...
@@ -565,7 +561,7 @@ FMT_INLINE std::basic_string<typename S::char_type> format(S, Args&&... args) {
if
(
str
.
size
()
==
2
&&
str
[
0
]
==
'{'
&&
str
[
1
]
==
'}'
)
if
(
str
.
size
()
==
2
&&
str
[
0
]
==
'{'
&&
str
[
1
]
==
'}'
)
return
fmt
::
to_string
(
detail
::
first
(
args
...));
return
fmt
::
to_string
(
detail
::
first
(
args
...));
constexpr
auto
compiled
=
compile
<
Args
...
>
(
S
());
constexpr
auto
compiled
=
compile
<
Args
...
>
(
S
());
return
format
(
compiled
,
std
::
forward
<
Args
...
>
(
args
...)
);
return
format
(
compiled
,
std
::
forward
<
Args
>
(
args
)...
);
}
}
template
<
typename
OutputIt
,
typename
CompiledFormat
,
typename
...
Args
,
template
<
typename
OutputIt
,
typename
CompiledFormat
,
typename
...
Args
,
...
...
test/compile-test.cc
View file @
16637341
...
@@ -142,3 +142,10 @@ TEST(CompileTest, EmptyFormatString) {
...
@@ -142,3 +142,10 @@ TEST(CompileTest, EmptyFormatString) {
auto
f
=
fmt
::
compile
<>
(
""
);
auto
f
=
fmt
::
compile
<>
(
""
);
EXPECT_EQ
(
fmt
::
format
(
f
),
""
);
EXPECT_EQ
(
fmt
::
format
(
f
),
""
);
}
}
#ifdef __cpp_if_constexpr
TEST
(
CompileTest
,
Basic
)
{
EXPECT_EQ
(
"42"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
42
));
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
FMT_COMPILE
(
"{}"
),
"foo"
));
}
#endif
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