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.
I'm encountering an issue with my code where I'm trying to bind a Python function to C++ code using Pybind11. The C++ wrapper accepts a std::function with two arguments obj1 & obj2 (both are classes), where one of the arguments, obj2, is non-copyable (obj1 is copyable)
Here's my code snippet:
block_processor.def(py::init([](std::function<void(obj1, obj2&)> processing_function) {
return new block_processor(processing_function);
}), "processing_function"_a)
When I run my Python code, I encounter the following error:
"return_value_policy = copy, but type obj2 is non-copyable!"
Upon debugging, I've identified that the problem occurs in the Pybind11 file pybind11/detail/type_caster_base.h in the cast function:
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.
I'm encountering an issue with my code where I'm trying to bind a Python function to C++ code using Pybind11. The C++ wrapper accepts a std::function with two arguments obj1 & obj2 (both are classes), where one of the arguments, obj2, is non-copyable (obj1 is copyable)
Here's my code snippet:
When I run my Python code, I encounter the following error:
Upon debugging, I've identified that the problem occurs in the Pybind11 file
pybind11/detail/type_caster_base.h
in the cast function:I cannot simply make obj2 a pointer to work around this issue. Do you have any suggestions on how to handle this situation?
Beta Was this translation helpful? Give feedback.
All reactions