-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add std::unique_ptr
support
#433
Conversation
In the current solution, when a function binding that return a It's maybe possible to overload I don't know if the second option is better. User have less code to write, but he should include the right header that will do some magic for him. @ManifoldFR, @jcarpent Any opinion ? (Not an emergency) |
Both solutions seem sound to me. If we go for an overload of |
It would be the safest option. I will investigate this solution then. It's not possible to do the same thing with |
Would it be possible to do it on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic @jorisv, thanks a lot
I have a few questions:
- whether
bp::register_ptr_to_python
can be used anywhere here as a shortcut, - whether
unique_ptr
can be used as a holder class (an argument in thebp::class_
template, the docs say one could expose a typeT
throughshared_ptr<T>
for instance) ; this is something Pybind11 does by default and I'm not sure whether boost.python already does that - whether
vector<unique_ptr<T>>
can be exposed
Ok, it's mandatory to define a new Policies. We can't specialize |
I don't know, it look like it doesn't manage the move like we are doing for unique_ptr.
When we transfer the ownership to python (return value) the
We have modify the std::vector binding to manage non copiable data |
OK, make sense.
After checking we saw that |
6615801
to
f7ecce2
Compare
…fault_call_policies
6bf31d4
to
a75379e
Compare
Best PR ever |
Upstream changelog: ## [3.4.0] - 2024-02-26 ### Added - Support for `Eigen::SparseMatrix` types (stack-of-tasks/eigenpy#426) - Support for `boost::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#430) - Support for `std::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#431) - Support for `std::unique_ptr` as a return types with `StdUniquePtrCallPolicies` and `boost::python::default_call_policies` (stack-of-tasks/eigenpy#433) - Support for `std::unique_ptr` as an internal reference with `ReturnInternalStdUniquePtr` (stack-of-tasks/eigenpy#433) - Support for `Eigen::Simplicial{LLT,LDLT}` and `Eigen::Cholmod{Simplicial,Supernodal}{LLT,LDLT}` Cholesky de compositions (stack-of-tasks/eigenpy#438) - Switch to ruff for lints, format, and import sort (stack-of-tasks/eigenpy#441) ### Fixed - Fix the issue of missing exposition of Eigen types with __int64 scalar type (stack-of-tasks/eigenpy#426) - Fix namespace use in unittest/std_pair.cpp (stack-of-tasks/eigenpy#429) - Fix case of zero-size sparse matrices (stack-of-tasks/eigenpy#437) Packaging changes: - remove patch-aa, fixed upstream
Upstream changelog: ## [3.4.0] - 2024-02-26 ### Added - Support for `Eigen::SparseMatrix` types (stack-of-tasks/eigenpy#426) - Support for `boost::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#430) - Support for `std::variant` types with `VariantConverter` (stack-of-tasks/eigenpy#431) - Support for `std::unique_ptr` as a return types with `StdUniquePtrCallPolicies` and `boost::python::default_call_policies` (stack-of-tasks/eigenpy#433) - Support for `std::unique_ptr` as an internal reference with `ReturnInternalStdUniquePtr` (stack-of-tasks/eigenpy#433) - Support for `Eigen::Simplicial{LLT,LDLT}` and `Eigen::Cholmod{Simplicial,Supernodal}{LLT,LDLT}` Cholesky de compositions (stack-of-tasks/eigenpy#438) - Switch to ruff for lints, format, and import sort (stack-of-tasks/eigenpy#441) ### Fixed - Fix the issue of missing exposition of Eigen types with __int64 scalar type (stack-of-tasks/eigenpy#426) - Fix namespace use in unittest/std_pair.cpp (stack-of-tasks/eigenpy#429) - Fix case of zero-size sparse matrices (stack-of-tasks/eigenpy#437) Packaging changes: - remove patch-aa, fixed upstream
std::unique_ptr
for function returnstd::unique_ptr
for function returnstd::unique_ptr
for member accessto_python_value
Fix #427