Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
733f8de2
Unverified
Commit
733f8de2
authored
Jul 01, 2021
by
jonathan-conder-sm
Committed by
GitHub
Jun 30, 2021
Browse files
Avoid string copy if possible when passing a Python object to std::ostream (#3042)
parent
cad79c11
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
include/pybind11/stl.h
include/pybind11/stl.h
+4
-0
No files found.
include/pybind11/stl.h
View file @
733f8de2
...
...
@@ -380,7 +380,11 @@ struct type_caster<std::variant<Ts...>> : variant_caster<std::variant<Ts...>> {
PYBIND11_NAMESPACE_END
(
detail
)
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
handle
&
obj
)
{
#ifdef PYBIND11_HAS_STRING_VIEW
os
<<
str
(
obj
).
cast
<
std
::
string_view
>
();
#else
os
<<
(
std
::
string
)
str
(
obj
);
#endif
return
os
;
}
...
...
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