forked from wlav/CPyCppyy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Carry a copy of the string also in the
std::string_view
converter
There are two possible fixes to the problem with string lifetimes and `std::string_view` arguments: * setting a lifeline * copying the string Copying the string is supposedly faster on average, at least in the ROOT usecase the strings that are passed around are not very long (RDataFrame filter and variable definitions). This commit fixes the following reproducer: ```Python import cppyy cppyy.cppdef(""" void foo(std::string_view s1, std::string_view s2) { std::cout << s1 << std::endl; std::cout << s2 << std::endl; std::cout << std::endl; } void bar(std::initializer_list<std::string_view> sl) { for (auto const& s : sl) { std::cout << s << std::endl; } std::cout << std::endl; } """) cppyy.gbl.foo("hello", "world") ``` Closes wlav#13.
- Loading branch information
1 parent
6539c24
commit a5222b7
Showing
2 changed files
with
25 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters