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
8c29459e
Commit
8c29459e
authored
Mar 21, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of empty string_view (#689)
parent
a24005d5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
include/fmt/format.h
include/fmt/format.h
+3
-4
test/format-test.cc
test/format-test.cc
+2
-1
No files found.
include/fmt/format.h
View file @
8c29459e
...
...
@@ -1399,8 +1399,9 @@ class arg_formatter_base {
}
void
write
(
const
char_type
*
value
)
{
auto
length
=
value
!=
FMT_NULL
?
std
::
char_traits
<
char_type
>::
length
(
value
)
:
0
;
if
(
!
value
)
FMT_THROW
(
format_error
(
"string pointer is null"
));
auto
length
=
std
::
char_traits
<
char_type
>::
length
(
value
);
writer_
.
write_str
(
basic_string_view
<
char_type
>
(
value
,
length
),
specs_
);
}
...
...
@@ -2647,8 +2648,6 @@ void basic_writer<Range>::write_str(
internal
::
char_traits
<
char_type
>::
convert
(
Char
());
const
Char
*
data
=
s
.
data
();
std
::
size_t
size
=
s
.
size
();
if
(
size
==
0
&&
!
data
)
FMT_THROW
(
format_error
(
"string pointer is null"
));
std
::
size_t
precision
=
static_cast
<
std
::
size_t
>
(
spec
.
precision_
);
if
(
spec
.
precision_
>=
0
&&
precision
<
size
)
size
=
precision
;
...
...
test/format-test.cc
View file @
8c29459e
...
...
@@ -1196,7 +1196,8 @@ TEST(FormatterTest, FormatString) {
}
TEST
(
FormatterTest
,
FormatStringView
)
{
EXPECT_EQ
(
"test"
,
format
(
"{0}"
,
string_view
(
"test"
)));
EXPECT_EQ
(
"test"
,
format
(
"{}"
,
string_view
(
"test"
)));
EXPECT_EQ
(
""
,
format
(
"{}"
,
string_view
()));
}
#ifdef FMT_USE_STD_STRING_VIEW
...
...
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