boostorg / boostorg/python

boost::python fails to handle std::unique_ptr as object holder

Open
#202 12 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
537
Forks
223
Avg merge
11h 22m
Merged PRs (30d)
2

Description

In ticket https://svn.boost.org/trac10/ticket/7711, 5 years ago, somebody complained that `std::unique_ptr` cannot be used as an object holder in boost::python. Although the ticket was closed, I still have the problem (in boost 1.58). Is there a solution available?

```cpp
#include
#include

struct Foo {};

BOOST_PYTHON_MODULE(foo) {
// This compiles fine.
boost::python::class_<
Foo
, std::auto_ptr
, boost::noncopyable
>("Foo1", boost::python::no_init)
;

// This doesn't compile.
boost::python::class_<
Foo
, std::unique_ptr
, boost::noncopyable
>("Foo2", boost::python::no_init)
;
}
```

Compile error (`std::unique_ptr` misses copy constructor):
`usr/include/boost/python/object/make_ptr_instance.hpp:24:38:
error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = moveit::python::Foo; _Dp = std::default_delete]’
`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.