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
72e519a4
Commit
72e519a4
authored
Jun 22, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add formatter<std::string_view>
parent
635e01fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
include/fmt/format.h
include/fmt/format.h
+1
-0
test/format-test.cc
test/format-test.cc
+13
-2
No files found.
include/fmt/format.h
View file @
72e519a4
...
...
@@ -3005,6 +3005,7 @@ FMT_FORMAT_AS(float, double);
FMT_FORMAT_AS
(
Char
*
,
const
Char
*
);
FMT_FORMAT_AS
(
std
::
basic_string
<
Char
>
,
basic_string_view
<
Char
>
);
FMT_FORMAT_AS
(
std
::
nullptr_t
,
const
void
*
);
FMT_FORMAT_AS
(
internal
::
std_string_view
<
Char
>
,
basic_string_view
<
Char
>
);
template
<
typename
Char
>
struct
formatter
<
void
*
,
Char
>
:
formatter
<
const
void
*
,
Char
>
{
...
...
test/format-test.cc
View file @
72e519a4
...
...
@@ -1590,9 +1590,20 @@ TEST(FormatterTest, FormatStringView) {
EXPECT_EQ
(
""
,
format
(
"{}"
,
string_view
()));
}
#ifdef FMT_USE_STD_STRING_VIEW
#ifdef FMT_USE_STRING_VIEW
struct
string_viewable
{};
FMT_BEGIN_NAMESPACE
template
<
>
struct
formatter
<
string_viewable
>
:
formatter
<
std
::
string_view
>
{
auto
format
(
string_viewable
,
format_context
&
ctx
)
->
decltype
(
ctx
.
out
())
{
return
formatter
<
std
::
string_view
>::
format
(
"foo"
,
ctx
);
}
};
FMT_END_NAMESPACE
TEST
(
FormatterTest
,
FormatStdStringView
)
{
EXPECT_EQ
(
"test"
,
format
(
"{0}"
,
std
::
string_view
(
"test"
)));
EXPECT_EQ
(
"test"
,
format
(
"{}"
,
std
::
string_view
(
"test"
)));
EXPECT_EQ
(
"foo"
,
format
(
"{}"
,
string_viewable
()));
}
#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