You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, All,
I'm confused with a seemingly trivial problem. The bindings of the method, which returns a class instance by value, generate an excessive call to copy constructor:
// The method
Selection System::select(int arg);
// The binding
.def("select", &System::select, py::return_value_policy::???)
// Generates an excessive copy of Selection on return
I've tried return_value_policy::move, which seems to be the correct behavior, but the call to copy constructor is generated anyway. Am I missing something? What is the correct idiomatic way of preventing excessive copy in such cases?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, All,
I'm confused with a seemingly trivial problem. The bindings of the method, which returns a class instance by value, generate an excessive call to copy constructor:
I've tried return_value_policy::move, which seems to be the correct behavior, but the call to copy constructor is generated anyway. Am I missing something? What is the correct idiomatic way of preventing excessive copy in such cases?
Beta Was this translation helpful? Give feedback.
All reactions