boostorg / boostorg/python

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

未關閉
#202 12 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
537
分支
223
平均合併
11 小時 22 分鐘
30 天內合併 PR
2

描述

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]’
`

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。