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
206000a0
Commit
206000a0
authored
Jun 06, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workaround pathological conversion (#2343)
parent
76ee4904
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
include/fmt/core.h
include/fmt/core.h
+1
-1
test/format-test.cc
test/format-test.cc
+21
-0
No files found.
include/fmt/core.h
View file @
206000a0
...
...
@@ -1539,7 +1539,7 @@ FMT_CONSTEXPR FMT_INLINE auto make_arg(const T& val) -> value<Context> {
!
std
::
is_same
<
decltype
(
arg
),
const
unformattable
&>::
value
,
"Cannot format an argument. To make type T formattable provide a "
"formatter<T> specialization: https://fmt.dev/latest/api.html#udt"
);
return
arg
;
return
{
arg
}
;
}
template
<
bool
IS_PACKED
,
typename
Context
,
type
,
typename
T
,
...
...
test/format-test.cc
View file @
206000a0
...
...
@@ -1436,6 +1436,27 @@ TEST(format_test, format_explicitly_convertible_to_std_string_view) {
}
#endif
struct
converible_to_anything
{
template
<
typename
T
>
operator
T
()
const
{
return
T
();
}
};
FMT_BEGIN_NAMESPACE
template
<
>
struct
formatter
<
converible_to_anything
>
{
FMT_CONSTEXPR
auto
parse
(
format_parse_context
&
ctx
)
->
decltype
(
ctx
.
begin
())
{
return
ctx
.
begin
();
}
auto
format
(
converible_to_anything
,
format_context
&
ctx
)
->
decltype
(
ctx
.
out
())
{
return
format_to
(
ctx
.
out
(),
"foo"
);
}
};
FMT_END_NAMESPACE
TEST
(
format_test
,
format_convertible_to_anything
)
{
EXPECT_EQ
(
"foo"
,
fmt
::
format
(
"{}"
,
converible_to_anything
()));
}
class
Answer
{};
FMT_BEGIN_NAMESPACE
...
...
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